Skip to content

Saved conversations follow the agent's answer settings in the API - #7

Merged
PradipNichite merged 4 commits into
mainfrom
fix/saved-conversation-visibility
Oct 23, 2026
Merged

PradipNichite merged 4 commits into
mainfrom
fix/saved-conversation-visibility

Conversation

@PradipNichite

@PradipNichite PradipNichite commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What changes

Same design as the hosted codebase, applied after independent review.

Session isolation (revises PR 6):

  • Chat history and saved replay read only the requesting agent's turns.
  • A session created on another agent is still refused with 404 before history or a model call.
  • A session_id the API never created continues with this agent's turns only. A chat service that sends its own thread id keeps working.
  • CSV export with an agent key finds only that agent's turns.
  • Feedback writes reach only the path agent's turns.

Visibility at the API: replay applies show_sql_query / show_db_result as the live answer does. It leaves out debug_info.sql_query, debug_info.db_output and the column-labelled result block. CSV export returns 403 for an agent that hides rows.

get_session_data requires agent_id and both flags.

Tests

  • tests/backend/test_session_scope.py (14 tests, offline).
  • tests/backend/test_session_storage.py (6 tests). It runs the product's queries on real PostgreSQL in a new session-storage CI job, including a thread id shared by two agents.
  • Red checks: removing a filter or a guard turns a suite red.

Local runs:

  • test_session_scope, test_selection_policy, tests/deployment (receipt updated) and tests/mcp: OK.
  • test_session_storage: 6/6 on a throwaway PostgreSQL.

🤖 Generated with Claude Code

PradipNichite and others added 4 commits October 23, 2026 21:13
Replay (GET /v1/agents/{id}/sessions/{sid} and .../messages) now leaves out the SQL and
the rows that show_sql_query / show_db_result hide -- debug_info.sql_query,
debug_info.db_output and the column-labelled result block -- exactly as the live answer
does. GET /v1/sessions/{sid}/export returns 403 for an agent that hides rows.
get_session_data requires both settings, so no caller can serve saved turns without them.

Previously only the MCP adapter applied the settings; a direct API caller with the same
key could read hidden SQL and rows. tests/backend/test_session_scope.py covers each route
with a visible and a hidden synthetic agent, plus a call-site gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d on another agent

Brings in the design accepted for the hosted codebase after independent review. The PR 6
check refused every session_id the API had not created itself, which breaks a chat service
that sends its own thread id as session_id. Isolation now lives in the reads:

- Chat history and saved replay read only the requesting agent's turns, so a shared or
  foreign session id can never put another agent's questions, answers, SQL or rows into
  this agent's context or replay.
- A session this API created for another agent is still refused (404) before history or a
  model call; an id the API never created continues with this agent's turns only.
- CSV export with an agent key finds only that agent's turns.
- tests/backend/test_session_storage.py runs the product's queries on real PostgreSQL in a
  new session-storage CI job, including a thread id shared by two agents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
add_user_feedback matched a turn by session_id and chat_id alone, so a key for one agent
could overwrite another agent's stored verdict and, with a corrected SQL, its sql_query,
which replay and export then serve. It now also matches the agent. Real-PostgreSQL test added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Matches the hosted codebase: each run creates and drops its own schema, so an older shape
of these tables left in a shared CI database cannot be kept by create_all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PradipNichite
PradipNichite merged commit a6b6c33 into main Oct 23, 2026
11 of 12 checks passed
@PradipNichite
PradipNichite deleted the fix/saved-conversation-visibility branch October 23, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant