fix(agents-runtime): carry message_type through inbox timeline so composer_input reaches the agent as text#4718
Open
andresberrios wants to merge 1 commit into
Conversation
…poser_input reaches the agent as text
buildInboxMessages dropped the message_type field when materializing the
entity timeline from the db. Without it, projectInboxPayload could no longer
recognize composer_input messages and fell back to JSON.stringify(payload),
so the model received `{"source":"..."}` instead of the plain text the user
typed. Carry message_type through and add a regression test that exercises
the db read path.
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.
Problem
Messages typed in the composer arrive to the agent as raw JSON — e.g. the model receives
{"source":"summarize the article"}instead of the plain textsummarize the article. This makes the agent respond about JSON rather than the actual message.Root cause
composer_inputinbox messages are projected to model text byprojectInboxPayload(timeline-context.ts), which extractspayload.source(orpayload.text) only whenitem.message_type === COMPOSER_INPUT_MESSAGE_TYPE. Otherwise it falls back toJSON.stringify(payload).When the entity timeline is materialized from the db,
buildInboxMessagesinentity-timeline.tsrebuilds each inbox row but dropsmessage_type. So by the timeprojectInboxPayloadruns,message_typeisundefined, thecomposer_inputbranch is never taken, and the raw payload is stringified.message_typeis present on the underlying collection row (MessageReceivedValue) and is already permitted onIncludesInboxMessage(theOmitdoesn't exclude it) — it was simply not copied through.Fix
Carry
message_typethroughbuildInboxMessages. One field; no type changes needed.Test
Added a regression test to
test/timeline-context.test.tsthat drives the db read path (timelineToMessages) with acomposer_inputrow and asserts the source text is extracted. The existing composer_input test only exercisedbuildTimelineMessageswith a hand-built timeline, so it bypassedbuildInboxMessagesand didn't catch this. Verified the new test fails before the fix and passes after.Notes
patchfor@electric-ax/agents-runtime).pnpm --filter @electric-ax/agents-runtime testpasses for the timeline suite. Two unrelated failures exist in a fresh clone and are not touched by this change:tool-providers.test.ts(can't resolve the unbuilt@electric-ax/agents-mcpsibling package) and a flaky heartbeat-timing assertion inpull-wake-runner.test.ts.