Skip to content

Drive TexeraAgent.sendMessage with a stand-in language model #7486

Description

@aglinxinyuan

Task Summary

sendMessage is the largest untested region in the whole service: lines 475–712 of
texera-agent.ts, 238 of the file's 292 uncovered lines. The existing 26-test spec stops at the
model boundary and never enters it, which leaves the ReAct loop, its usage accounting, its branch
bookkeeping, and every one of its failure paths unexercised.

None of that needs the network. ai@7.0.48 ships MockLanguageModelV4 from the ai/test export,
and it satisfies the same LanguageModel type TexeraAgentConfig already accepts — so the loop can
be driven in-process, with fetch spied on as a tripwire to prove no call escapes.

Five traps are worth writing down, because each one produces a test that passes while asserting
nothing:

  1. LanguageModelV4Usage is nested. A flat { inputTokens: 11 } is silently discarded and
    every usage assertion then passes against a gutted mapping.
  2. LanguageModelV4FinishReason is an object ({ unified, raw }), not a string. A bare
    finishReason: "stop" runs fine under bun test and fails tsc --noEmit.
  3. A tool call's input must be a JSON string, not an object.
  4. Setting a delegate config makes the first turn refresh from the backend, and that refresh
    replaces the whole workflow — operators seeded directly on the agent are wiped, so they have to
    arrive through the fetch stub.
  5. maxSteps: 0 is an infinite loop. stepCountIs(0) never fires. Do not write that test; it
    hangs the suite rather than failing it.

Only getStepsById (line 261) would remain uncovered, and it has no call site anywhere in the repo.

Task Type

  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions