Repository navigation
fix(labs/claude-code-style): title sessions with the generator, not the first message - #4819
Conversation
…he first message The lab's sessions list titled every session by the first line of its first message, and never read the title the session stored. The main worker's flow also ran no title generator, so nothing ever wrote one. - fsdev.config.mts: the `agent` flow runs core's sessionTitleGenerator as its afterAnswer step, on the utility model the lab already names. - adapter.ts: a row reads the stored title first. The first message is a fallback only once a turn has ended with no title, and never while a turn runs. The first-line cache holds only what it read. - src/lib/session-title.ts: the title rule as a pure function, with tests that pin the rule (generated wins, no raw message mid-turn, blank title counts as none, fallback width). Not verified end to end: no live model run. Generation failures are inferred from "turn ended, still untitled", since the side chain's failure is not recorded on the session. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
… title lands Per review: the first message's first line stays the title whenever no generated title exists, as the lab showed before. The "only after a turn ends" gate is dropped. Titling already runs as a sidechain (afterAnswer is wired with .sideChain), so no flow change is needed. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
…idechain The lab titles sessions with core's sessionTitleGenerator as the agent flow's afterAnswer. Nothing tested that path, so a regression would leave sessions on the first-message fallback without any failing check. The new test runs one turn through testFlow (the server's runAction, which drains side chains) and checks two things: a generator result lands on the stored session title, and a generator that fails validation leaves the session untitled while the turn still completes with its answer. The failure case was confirmed from the trace: auto-title and the after-answer rescue both report failed. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
| it("leaves the session untitled when generation fails, and the turn still completes with its answer", async () => { | ||
| const failing = mockGenerator({ name: "auto-title:generate", script: [{ text: "not a title object" }] }); | ||
|
|
||
| const { result, session, answer } = await runTurn(failing); | ||
|
|
||
| expect(result.status).toBe("completed"); | ||
| expect(answer.calls).toHaveLength(1); | ||
| expect(session?.title).toBeUndefined(); | ||
| }); |
There was a problem hiding this comment.
💡 Quality: Failure-path test passes even if the title generator never runs
The second test in agent-session-title.test.ts checks that session.title is undefined and that the turn completed. It never checks that the failing generator was actually called. If the afterAnswer sidechain were skipped, dropped, or wired under the wrong generator name, the session would still have no title and the test would still pass. So it doesn't show what its name claims: that a generation failure is contained and the turn still answers. This is the kind of test CLAUDE.md #5 rules out. Fix: assert failing.calls has length 1, as the first test does for titler.
Assert the failing generator ran, so the test checks that a failure is contained rather than that nothing ran:
expect(result.status).toBe("completed");
expect(answer.calls).toHaveLength(1);
expect(failing.calls).toHaveLength(1);
expect(session?.title).toBeUndefined();
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 0 closed / 1 findings🟡 Medium risk · Running the title generator after every agent turn adds recurring model cost and could delay turn completion while its sidechain drains. Titles sessions with the stored generator result, falling back to the first message's first line until one lands. Approved with a suggestion: the failure-path test in 💡 Quality: Failure-path test passes even if the title generator never runs📄 packages/workforce/test/agent-session-title.test.ts:67-75 The second test in Assert the failing generator ran, so the test checks that a failure is contained rather than that nothing ran🤖 Prompt for agentsVerificationRules No rules evaluated Functional validation Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
Second look + architecture reviewVerdict: the approach is right. It reuses core's 1. A new title may not reach the sessions list (needs checking)
2. Cost: the generator runs on every turnThe PR already notes this. The generator is written to re-title, so it can't simply be stopped after turn 1. But for a lab that wants a title once, 3. Failure is silent and invisibleA generator that fails validation leaves the session untitled. The test pins this (good), but nothing records it, so the first-line fallback shows forever. Combined with (2), a gated generator would never retry after a failure. That is another reason to prefer "run every turn until a title exists", i.e. gate on no title and not on first turn. 4. Small cleanups (optional)
5. Test placement
Architecture opportunitiesNone worth taking in this PR. The adapter's row-building is already one function, and the title rule is now pure and unit-tested. I'd leave Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e0b99a90f3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| installation, | ||
| model, | ||
| ...answerAgain, | ||
| afterAnswer: utility.sessionTitleGenerator({ name: "auto-title", model: utilityModel }), |
There was a problem hiding this comment.
Prevent title-generation errors from failing delegated tasks
When a delegated desk.researcher task returns its result to its filer (the default), a title-model error or invalid structured output now fails an otherwise successful task attempt. afterAnswerStep only rescues failures for resultTo: "conversation"; other failures reach task-request.ts, where ending.backgroundFailures fails the attempt. Repeated title failures can therefore exhaust retries and discard successful research merely because its session could not be titled. Rescue errors around the cosmetic title generator itself so delegated task success does not depend on title generation.
Useful? React with 👍 / 👎.
Summary
Why the adapter change
The adapter's title cache held the first line forever, so a generated title could never replace it. The cache now holds only the first line it read, and the title rule lives in `src/lib/session-title.ts` as a pure function.
Tests
Known limits
🤖 Generated with Claude Code