feat(assistants): implement Codex rollout-based file attachment detection - #466
Open
Sergei-Nikitin-epam wants to merge 6 commits into
Open
feat(assistants): implement Codex rollout-based file attachment detection#466Sergei-Nikitin-epam wants to merge 6 commits into
Sergei-Nikitin-epam wants to merge 6 commits into
Conversation
…oad detection Replace broken two-pass buildAttachmentMap (wrong JSONL structure assumption) and RECENT_MESSAGES_LIMIT=2 (too narrow for real sessions with tool-result messages) with a turn-boundary backward scan that stops at the most recent assistant message. Real Claude Code JSONL has isMeta=true messages carrying both base64 attachment data and [Image: source: /path] filename text in the same message object. The old code expected base64 in a non-meta parent and filename text in a meta child, so the attachment map was never populated and zero files were returned. The scan window of 2 also broke in real sessions where tool-result messages at positions 1-2 pushed the image meta message to position 3, outside the window. EPMCDME-13907
…ude sessions The previous turn-boundary scan (stopping at type==='assistant') failed in real Claude Code JSONL because: - Bug A: the assistant tool_use entry appears *after* the user's isMeta messages for the same prompt, so the scan broke before reaching the images. - Bug B: base64 data and the [Image: source: /path] filename live in two *separate* isMeta entries (not the same one), so the old single-message pass produced the image with a fallback filename. Fix: use the promptId field that Claude Code stamps on every message in a single prompt turn. Find the most recent non-meta user message, capture its promptId, collect all isMeta messages sharing that id, gather filenames across them first, then match positionally to base64 attachment items. Also adds promptId to the ClaudeMessage interface and updates test fixtures to reflect the real split-message JSONL structure. Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
…t --conversation-id --conversation-id identifies the assistant chat thread (e.g. a workflow_id generated by a skill). CODEMIE_SESSION_ID identifies the Claude session whose JSONL contains uploaded file blobs. Using --conversation-id for session lookup caused detectFileUploadsFromSession to look for a non-existent session file, returning no attachments even when files were uploaded in the current Claude turn. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0162w98kuqJ7EWaA6h2FjDCK
…tion Adds detectCodexFileUploads() which discovers the active Codex rollout by scanning ~/.codex/sessions via getCodexDiscoverySessionRoots() and matching session_meta.cwd to the caller's CWD. Extracts input_image blocks from the most recent user response_item record. Wires CODEMIE_AGENT-aware dispatch in chat/index.ts: when CODEMIE_AGENT equals 'codex', the new detector runs; otherwise the existing Claude CODEMIE_SESSION_ID path is used (no regression). Also adds CodexResponseItemMessage, CodexContentBlock, and extends CodexEventMsg with images/local_images to make attachment types explicit. Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
- CR-001: use imageOnlyIndex (increments only on input_image) for local_images lookups; the prior localImageIndex incremented on input_file blocks too, misaligning filename resolution in mixed file+image turns - CR-002: find targetEventMsg in a second backward pass bounded to records at or before the response_item position, so a follow-up message no longer severs the filename chain from the attachment turn - CR-003: estimate decoded size with base64 length math before the size guard, avoiding a full Buffer.from allocation that could OOM and silently drop valid attachments; also reject empty data URI payloads early Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
Planning, review, and complexity-assessment artifacts for the Codex file attachment detection implementation (sdlc-light flow). Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
codexUploadsDetector.ts: scans Codex session directories for the rollout whosesession_meta.cwdresolves to the current working directory, then extractsinput_imageblocks from the most-recent user turn using a two-pass scancodex-message-types.tswithCodexResponseItemMessageandCodexContentBlockinterfaces; addsimages,local_images, andtext_elementsfields toCodexEventMsgCODEMIE_AGENT === 'codex'dispatch gate inchat/index.ts— Codex sessions take the new path, Claude sessions continue to useCODEMIE_SESSION_ID-based detectionAchieves feature parity with the Claude file attachment detector. No regression on the Claude path (covered by EPMCDME-13907 cherry-picks on this branch).
Why direct rollout scanning
Codex hooks do not fire reliably, so hook-based session correlation is skipped.
CodexSessionAdapterrequiresAgentMetadata.dataPaths.homewhich is unavailable in the CLI layer. The detector usesgetCodexDiscoverySessionRoots()+readJSONLTolerantdirectly and matches sessions by CWD realpath (symlink-tolerant).Changes
src/cli/commands/assistants/chat/codexUploadsDetector.ts(new) — rollout discovery, two-pass extraction, OOM-safe base64 size guardsrc/agents/plugins/codex/codex-message-types.ts—CodexResponseItemMessage,CodexContentBlock,CodexEventMsgextensionsrc/cli/commands/assistants/chat/index.ts— agent-aware detection dispatchTest plan
codemie assistants chat <id> "message"inside an active Codex session — verify attached image is detected and uploadedCODEMIE_AGENTis unset (Claude path unchanged)imageOnlyIndexfix)Fixes: EPMCDME-13885