Repository navigation
feat(chat): each answer records what produced it - #469
Merged
Merged
Conversation
Importing app.domain.ai_tools on its own failed: it imported automations, which loads the actions, and the agent's action subclasses Toolbox before ai_tools had defined it. Running one test file (tests/api/test_chats.py) hit it. ai_tools now imports automations last. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
Every answer keeps `meta`: the model and the host name of its server,
the tools offered and asked for, the scope it answered in (after
auto-scope), its limits and what it used, how it ended (answered,
direct, limit, fallback, stopped, error), tool results that read like
instructions to an AI, how long it took, Lens's version, and tokens and
cost from the ledger rows that name it. Questions keep how they were
sent (web, api, voice, room, automation) and their options.
The answer's id is taken once the question is saved and the answer
runs in activity.scope(chat:<cid>, chat_message:<mid>), in the web
chat, chat rooms and the automations' agent; the streamed answer holds
the scope across its steps (activity.scoped). App completions keep no
messages, so their record comes back in lens.record. The stream sends
`meta` before `done`; GET /chats/{cid}/messages/{mid} returns one
message with its record and ledger rows. Each tool step keeps its time
and whether it failed. The web app shows it all from an i in the
answer's header (a sheet on a phone); old answers say they weren't
recorded.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
…-r960xc-c1-record
The last check asked for 2026-10-17's note after the call without a date had made today's note, so on that day it found the note the deleted root had left behind. It now asks for a day no earlier call makes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
Owner
Author
|
I ported the fix from #470 here in acf97d7. Without it, Generated by Claude Code |
The answer's record uses C2's reserved answer_id for its ledger scope and is saved under the question (parent); a message of any version can be read with its record and ledger rows. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
# Conflicts: # threat-model.yaml
19 of 22 tasks
Keeps C2's versions UI (regenerate, parent, VersionSwitch) with the answer's Details and record; a question said in voice mode still sends via. useIsNarrow lays out wide where there's no matchMedia, as Details now renders in every saved answer's header. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
Keeps the sandbox import and web citations (web pages stay; recordings follow access) with get_message's readable-citation helper; prose_version is the sha256 of the merged threat-model.md. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
19 of 22 tasks
adeelahmad
pushed a commit
that referenced
this pull request
Oct 17, 2026
#469 merged while this was open: its line moves from In progress to the built list, with its checks. The scorecard (#487) is merged too, so Planned keeps only what it doesn't measure yet. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MTK8aqzLBhdhfCmVf2LaWZ
19 of 22 tasks
adeelahmad
pushed a commit
that referenced
this pull request
Oct 17, 2026
C1 (#469), web search (#472) and the sandbox (#473) are in main. The routes keep C5's web pages in citations alongside the export, and the export test now checks a cited web page stays through access changes. The OpenAPI schema and client are regenerated with make openapi's two commands, and the threat model's prose_version is recomputed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
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.
Requested by Adeel · project thread
Description
Before: an answer showed only the model that wrote it. Nothing said which tools it was offered, what scope it answered in, how many rounds it used, what it cost or how it ended, and ledger rows named the conversation but not the answer.
After: every answer keeps a record (
meta): the model and the host name of its server (never the address or key), the tools offered and asked for, the scope after auto-scope, its limits and use, how it ended (answered,direct,limit,fallback,stopped,error), tool results that read like instructions to an AI, how long it took, Lens's version, and tokens and cost from the ledger rows that name it. Questions keep how they were sent (web,api,voice,room,automation) and their options. An i in the answer's header opens Details (a sheet on a phone) with all of it, the calls made for it and the conversation's cost this month; old answers say they weren't recorded. Each tool step shows how long it took and whether it failed.How: the answer's id is taken right after the question is saved, and the answer runs in
activity.scope(chat:<cid>, chat_message:<mid>)in the web chat, chat rooms and the automations' agent. A streamed answer can't hold awithscope across its yields (each step runs in a fresh copy of the request's context in the threadpool), soactivity.scoped()enters it per step. The stream sendsmetajust beforedone;GET /api/v1/chats/{cid}/messages/{mid}returns one message with its record and ledger rows. App completions keep no messages, so their record comes back inlens.record, without tokens and cost.Motivation and Context
Module C1 of the chat-gaps plan: record all data about a response (tools, model, scope), so people can trust and debug answers and agents can read them.
Screenshots (if appropriate):
n/a (jest renders the popover and the phone sheet).
Steps to reproduce (if appropriate):
Ask anything in Chat, then press the i next to the answer's model.
Types of changes
!in the title)Checklist:
tests/api/test_chat_records.py; records in rooms, the agent, completions and flagged tools;__tests__/chat-details.test.tsx).docs/accordingly (assistant.md › What each answer records, api.md, database.md › Upgrades).## UnreleasedinCHANGELOG.md.Done questions (AGENTS.md)
GET /chats/{cid}andGET /chats/{cid}/messages/{mid}return the record and ledger rows; completions returnlens.record. No assistant tool: the assistant can't usefully read its own record. MCPread_chatcomes with C3.chat_message:<id>activity; the record names the model server's host name only; threat model outputs table updated.metaand readers show what's there (docs/database.md › Upgrades).make openapi).Local checks: backend
pytest -n 41332 passed, 20 skipped; ruff, ruff format and mypy clean; frontend jest 139 suites / 962 tests passed, tsc and eslint clean;mkdocs build --strictclean;ci/validate_threat_model.pyagrees; OpenAPI regenerated and matches.Generated by Claude Code