BUG/PERF: read/control API endpoints create ghost AgentContexts for unknown IDs #182
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nsaspy/a0-symbolics#182
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Finding
ApiHandler.use_context()defaultscreate_if_not_exists=True, and many endpoints that are semantically read/control operations on an existing context call it without overriding that default.Examples:
api/chat_export.py: exporting an unknownctxidconstructs a brand-new context and serializes that instead of returning not-found.api/history_get.py: history lookup for an unknown ID creates an empty context and returns its history/token count.api/chat_reset.py: resetting an unknown ID creates a context, resets it, persists it and removes its message-files path.Each accidental creation runs
initialize_agent(), profile reconciliation andAgentContextregistration. The ghost context then participates in global roster/state work and may later be persisted. Bad/stale browser IDs or API clients can therefore inflate memory/chat lists simply by reading or controlling nonexistent contexts.This also makes endpoint semantics surprising: a typo is transformed into a successful new resource rather than a 404/conflict.
Direction
Split context access into explicit APIs:
require_context(id)/ lookup-only: never creates; returns typed not-foundcreate_context(...): creation-only with collision checks (#44) and validated IDs (#43)get_or_create_contextonly for the narrow flows that intentionally need itDo not keep a default-to-create helper on generic read/control endpoints.
Acceptance
chat_export,history_get,chat_reset, pause/nudge and other existing-resource operations return not-found for unknown IDs and never register a new context.self.use_context(...)/ shared context helper call and classify creation intent explicitly.AgentContext.all()or the chat roster.Mirrored from
lost-rob0t/a0-symbolics#45via tracker sync.