Fix: Harden sandbox chat attachments, session history, and stream lifecycle#39
Fix: Harden sandbox chat attachments, session history, and stream lifecycle#39
Conversation
|
@codex review it |
There was a problem hiding this comment.
💡 Codex Review
spoon-bot/spoon_bot/gateway/api/v1/agent.py
Line 736 in 0b44b0b
thinking argument in voice streaming
After _stream_sse() gained the new attachments positional parameter, this streaming call was not updated. POST /v1/agent/voice/chat with stream=true will now raise TypeError (missing 1 required positional argument: 'thinking') before any bytes are sent, so voice streaming is completely broken on this path.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review again and resolve conversations |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04724ebf2b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review again |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 289ff98a99
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| extras["media"] = _validate_media_paths(_string_list_from_any(extras.get("media"))) | ||
| if "attachments" in extras: | ||
| extras["attachments"] = _validate_attachment_paths( | ||
| _normalize_attachment_refs(extras.get("attachments")) | ||
| ) |
There was a problem hiding this comment.
Validate imported attachment refs before clearing the session
These new import-time validations run after session.messages.clear() has already executed a few lines above. That means an import with one bad media or attachments path now returns an error but leaves the existing session emptied in memory, so a failed session.import can destroy the user's current history. Build and validate the replacement message list first, then swap it into the live session only after validation succeeds.
Useful? React with 👍 / 👎.
|
@codex review and list all the issues at one time |
There was a problem hiding this comment.
💡 Codex Review
spoon-bot/spoon_bot/gateway/websocket/handler.py
Lines 1077 to 1081 in e71b96a
This except Exception converts bad media/attachments imports into a normal {"success": false} response instead of the standard WS error frame. handle_request() only emits type: "error" / INVALID_PARAMS when a ValueError escapes, so clients that rely on WS error semantics will miss invalid import failures and can treat the import as successful. This happens for any session.import payload containing an out-of-workspace or missing file reference.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| resolved = _resolve_workspace_file(path) | ||
| if resolved is None: | ||
| invalid.append(path) | ||
| continue | ||
| resolved_media.append(str(resolved)) |
There was a problem hiding this comment.
Preserve portable media URIs instead of host paths
By replacing each accepted media entry with str(resolved), the request loses the original /workspace/... URI and stores a host-specific absolute path instead. AgentLoop persists that list verbatim and session.export returns it verbatim, while session.import revalidates media against the current workspace root; as a result, a session exported from one sandbox/workspace will fail to import into another even when the same file exists there. This breaks round-tripping for any conversation that included media.
Useful? React with 👍 / 👎.
Description
This PR improves
spoon-botbehavior in sandbox chat by fixing stale request leakage, making attachment handling workspace-safe, and preserving structured attachment context across session/history flows.What this PR changes
think()wrapping request-scoped instead of stacking across requeststhink()implementation afterprocess,stream, andprocess_with_thinkingrun()tasks when a streamed request is cancelled or the stream is closedattachmentsalongsidemediain websocket and REST chat entrypointsattachmentsandmediain session history instead of flattening everything to plain textWhy
Before this change, sandbox conversations could drift in a few bad ways:
media/attachmentsTogether, these issues made sandbox attachment-based answers unreliable and could cause cross-request task leakage.
Expected result