Skip to content

feat(chat): show approvals, policy denials and connector calls in chat - #110

Merged
jbouder merged 4 commits into
mainfrom
feat/79-chat-tool-states
Dec 3, 2026
Merged

jbouder merged 4 commits into
mainfrom
feat/79-chat-tool-states

Conversation

@jbouder

@jbouder jbouder commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • The broker marks a policy denial with structured content, {"outcome":"denied_policy","message"}, for reads and for writes denied while they are planned. The error text is unchanged.
  • A pi extension (chat-results.mjs) keeps a Tapas tool's approval or denial mark in the saved result's details, so a reloaded conversation keeps it. chat-start.sh loads it through a new chat-bridge --pi-extension flag.
  • The chat bridge sets toolMetadata.tapas on the tapas server's held plans and policy denials, live and from history. Other servers' results are never read for marks.
  • The chat shows a connector call with its service's logo, the action in words, and whether it reads or writes. A held change shows the Approvals card inline, and the card follows decisions made elsewhere. A denial says why, apart from failures, with no retry.
  • docs/architecture/contracts.md documents the new denial content and the bridge's tool metadata.

Why

Refs #79. Connector calls, policy denials and pending approvals all looked like raw tool output in chat.

Also in this PR

Found while testing on a local cluster:

  • pi-setup declares connector tools to pi directly (exposure: hidden, toolExposure: {"*__*": "direct"}). Pi's default, codemode, kept them from the model, and a script's call would show as one codemode step that the chat can't mark. Tapas's own tools stay hidden; the agent uses javo-api.
  • Without the helper, pi-setup takes away the tapas server it wrote (from the feat(agents): pi reaches its owner's connectors through the helper's /mcp #70 review).
  • Approving or declining on the chat's card sends pi the outcome, so the conversation goes on. A decision made on the Approvals page updates the card but sends nothing.
  • The chat's pi extension adds a note after a held plan's result, so pi stops sending the approve link under the card. The broker's result is unchanged. contracts.md covers it.

#70 and #71 are merged, and this branch is rebased on main.

How to test

  • go test ./internal/chatbridge/ ./internal/connectors/broker/
  • node --test pod/files/agents/*.test.mjs
  • cd ui && npm test -- ToolCall
  • In a cluster with connectors on: restart the chat app, then ask the chat to make a connector write that policy holds for approval. Approve it from the chat card and check pi goes on without a link. Approve another from the Approvals page and check the card updates. Ask for a call policy denies and check it shows the reason with no retry. Reload and check the states persist.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QW4EewVw4PsagWuFNuGMGY

jbouder and others added 4 commits December 3, 2026 17:01
- The broker marks a policy denial with structured content,
  {"outcome":"denied_policy","message"}, for reads and for writes
  denied while they are planned. The error text is unchanged.
- A pi extension (chat-results.mjs) keeps a Tapas tool's approval or
  denial mark in the saved result's details. pi saves no structured
  content, so a reloaded conversation would lose it. chat-start.sh
  loads it through a new chat-bridge --pi-extension flag.
- The chat bridge sets toolMetadata.tapas on the tapas server's held
  plans and policy denials, live and from history. Other servers'
  results are never read for marks.
- The chat shows a connector call with its service's logo, the action
  in words and whether it reads or writes. A held change shows the
  Approvals card inline, which follows decisions made elsewhere. A
  denial says why, apart from failures, with no retry.

Refs #79

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QW4EewVw4PsagWuFNuGMGY
- pi-setup writes the tapas server with exposure hidden and
  toolExposure {"*__*": "direct"}. Pi's default, codemode, kept the
  connectors' tools from the model, so it never called them, and a call
  from a script would show in chat as one codemode step, not as a
  connector call the chat can mark.
- Tapas's own tools stay hidden. The agent reaches the API through
  javo-api.
- Without the helper, pi-setup takes away a tapas server it wrote,
  which would point at a helper that is not there. A person's own
  tapas server is kept.

Refs #79

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QW4EewVw4PsagWuFNuGMGY
- Approving or declining a held change on the chat's card sends pi a
  message with the outcome ("I approved notes-create-page in Notes,
  and it ran."), so the conversation goes on. Before, pi only learned
  the change was held, and the chat stopped there.
- Queued messages wait for a streaming reply to finish before they go.
- A decision made on the Approvals page or in another tab still shows
  on the card, but sends nothing, so two open tabs cannot both send it.

Refs #79

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QW4EewVw4PsagWuFNuGMGY
- The chat's pi extension adds a note after a held plan's result: the
  person decides on the card in the chat and pi gets a message with the
  decision, so pi does not send the approve link. Pi said "approve it
  there" with a link, under the card that already asked.
- Only the chat's pi gets the note. The broker's result, which terminal
  agents read, is unchanged, and so are denials.
- contracts.md describes the note.

Refs #79

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QW4EewVw4PsagWuFNuGMGY
@jbouder
jbouder force-pushed the feat/79-chat-tool-states branch from 9b2b8e2 to 3a2f338 Compare December 3, 2026 22:16
@jbouder
jbouder merged commit 53c4e89 into main Dec 3, 2026
22 checks passed

This branch was successfully deployed

1 active deployment
ui-preview — 3a2f338d Deployed Dec 3, 2026 by jbouder via Deploy to Cloudflare Pages #18
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