fix(api): message fetch limit exceeds API cap, silencing the subconscious - #52
Open
VooDooDood wants to merge 1 commit into
Open
VooDooDood wants to merge 1 commit into
VooDooDood wants to merge 1 commit into
Conversation
…ious
`fetchAssistantMessages` requests `limit=300` from
`GET /v1/conversations/{id}/messages`. The API caps `limit` at 200 and
rejects larger values with HTTP 422:
{"type": "less_than_equal", "loc": ["query", "limit"],
"msg": "Input should be less than or equal to 200", "ctx": {"le": 200}}
The `!response.ok` branch treats any failure as "no messages" and returns
an empty array, so the UserPromptSubmit hook emits
`<!-- No new messages from ... -->` on every prompt.
The effect is that the subconscious can never speak. The agent receives
transcripts and replies normally — the replies are visible in the
conversation via the API — but no reply ever reaches Claude Code. It reads
as an agent that has nothing to say rather than as a failure.
Introduced in 8adae7c, which raised the limit from 50 to 300 as an
incidental change inside an unrelated Windows console fix.
Lowering to 200 keeps the intent of the original bump (reach past
reasoning/tool entries to the newest assistant message) at the highest
value the API accepts. Verified against Letta Cloud: whisper delivery
restored on the first poll.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a Letta Cloud API incompatibility that prevented the subconscious from delivering assistant messages by reducing the message fetch limit to the API’s maximum accepted value, avoiding an HTTP 422 that was previously swallowed and interpreted as “no new messages.”
Changes:
- Reduce Letta messages fetch
limitfrom 300 to 200 to stay within the API cap. - Add an inline note documenting the 200 hard ceiling and why exceeding it causes silent failure.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
The subconscious currently cannot deliver any message to Claude Code when running against Letta Cloud. It installs, connects, receives transcripts, and replies normally — but no reply ever reaches the session.
Cause
fetchAssistantMessagesinscripts/sync_letta_memory.tsrequestslimit: 300:The API caps
limitat 200 and rejects anything larger with HTTP 422:{"type": "less_than_equal", "loc": ["query", "limit"], "msg": "Input should be less than or equal to 200", "input": "300", "ctx": {"le": 200}}The next branch swallows it:
So every fetch fails, every fetch is silently treated as "nothing new", and the
UserPromptSubmithook emits<!-- No new messages from ... -->on every single prompt.The failure is invisible from the user side. There is no error, no warning, no degraded mode — the agent simply appears to have nothing to say. Users reasonably conclude the subconscious is uninteresting or broken rather than that delivery is failing.
Reproduce
Alternatively: run any session, confirm via the API that the agent has produced
assistant_messageentries, and observe that the hook still reports no new messages.Origin
Introduced in 8adae7c, which raised the limit from 50 to 300. That change was incidental to the commit it rode in on (
fix(windows): eliminate console window flashes using PseudoConsole), which is likely why it escaped review.04c3423later refactored the URL construction but preserved the value.Fix
Lower to 200 — the highest value the API accepts. This preserves the intent of the original bump (reach back past
hidden_reasoning/tool entries to the newestassistant_message) while staying inside the cap. A comment is added so the ceiling is not re-raised later.200 is comfortably sufficient in practice: the hook advances its
lastSeenMessageIdbookmark on every prompt, so the window only has to span a single turn, and a turn costs a handful of entries. If the bookmark ever did fall outside the window,findIndexreturns-1and the code re-delivers rather than dropping — so the degradation is duplication, not silence.Scope
Verified against Letta Cloud (
api.letta.com), where whisper delivery was restored on the first poll after the change. Self-hosted servers are likely affected identically — the rejection is a Pydantic validation error from the route definition rather than cloud-side configuration — but I have not tested a self-hosted instance directly.🤖 Generated with Claude Code