Description
buildMarkdownContext() concatenates every AI text response from the turn
into a single prompt with no length limit. When the concatenated context
exceeds the model's context window (e.g. 131K tokens on Groq Developer
plan), the API returns HTTP 400 "Please reduce the length of the messages
or completion." Tool inputs are individually truncated via
MAX_TOOL_INPUT_LENGTH (100 chars), but AI text responses are concatenated
unfiltered. No config option exists to cap total prompt size.
Steps to Reproduce
- Configure opencode-mem with memoryModel: "llama-3.3-70b-versatile"
via Groq (memoryApiUrl: "https://api.groq.com/openai/v1").
- Have a conversation with multiple turns containing large AI responses
(file contents, code blocks, long explanations).
- Wait for auto-capture on idle.
- Observe the log: "OpenAI Chat Completion API error" with status 400
and the error body shown under Actual Behavior, repeated across all
autoCaptureMaxRetries attempts.
Expected Behavior
The conversation summary is generated successfully regardless of session
length — either because the model handles the full context or because the
prompt is truncated to fit within the model's context window.
Actual Behavior
Groq returns HTTP 400:
Please reduce the length of the messages or completion.
All attempts up to autoCaptureMaxRetries fail identically. Prompts are
permanently abandoned after the final retry.
Location
- File: src/services/auto-capture.ts
- Functions: extractAIContent (collects all text responses unfiltered)
and buildMarkdownContext (line with textResponses.join("\n\n"))
- Key line: sections.push(textResponses.join("\n\n")); (approx line 256)
- Commit: cfbe178 on main (identical in v2.22.2 at ab0a940)
Impact
Auto-capture silently fails for conversations that produce large AI
responses, even when the model's context window is theoretically adequate
for a concise summary. The prompts are permanently abandoned — the same
batch is never re-processed after quota resets, model changes, or
restarts.
Description
buildMarkdownContext() concatenates every AI text response from the turn
into a single prompt with no length limit. When the concatenated context
exceeds the model's context window (e.g. 131K tokens on Groq Developer
plan), the API returns HTTP 400 "Please reduce the length of the messages
or completion." Tool inputs are individually truncated via
MAX_TOOL_INPUT_LENGTH (100 chars), but AI text responses are concatenated
unfiltered. No config option exists to cap total prompt size.
Steps to Reproduce
via Groq (memoryApiUrl: "https://api.groq.com/openai/v1").
(file contents, code blocks, long explanations).
and the error body shown under Actual Behavior, repeated across all
autoCaptureMaxRetries attempts.
Expected Behavior
The conversation summary is generated successfully regardless of session
length — either because the model handles the full context or because the
prompt is truncated to fit within the model's context window.
Actual Behavior
Groq returns HTTP 400:
Please reduce the length of the messages or completion.
All attempts up to autoCaptureMaxRetries fail identically. Prompts are
permanently abandoned after the final retry.
Location
and buildMarkdownContext (line with textResponses.join("\n\n"))
Impact
Auto-capture silently fails for conversations that produce large AI
responses, even when the model's context window is theoretically adequate
for a concise summary. The prompts are permanently abandoned — the same
batch is never re-processed after quota resets, model changes, or
restarts.