Skip to content

feat: Add workspace-level chat#931

Draft
adavyas wants to merge 4 commits into
mainfrom
adavya/dev-1326
Draft

feat: Add workspace-level chat#931
adavyas wants to merge 4 commits into
mainfrom
adavya/dev-1326

Conversation

@adavyas

@adavyas adavyas commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What

POST /v3/workspaces/{workspace_id}/chat — agentic dialectic over the whole workspace instead of a single (observer, observed) pair. Successor to #373, salvaged and re-grown on today's DialecticAgent.

Closes DEV-1326.

Design

  • WorkspaceDialecticAgent subclasses DialecticAgent through four small seams added to the base class (_get_tools, _create_tool_executor, _prefetch_intro, _trace_name) rather than feat: workspace-level chat #373's base-class extraction — the pair agent's hot path is untouched.
  • Routing-accelerated prefetch: workspace stats + top-5 active peers + their self peer-cards, pure DB (~7ms measured, vs the pair agent's 2×25-doc semantic prefetch). The point: routing-obvious queries should resolve without a discovery tool round; each avoided round is a full model turn (~1.3s measured in the .chat latency study).
  • Observation search stays pair-scoped. A workspace-flat top-k would be dominated by the most verbose peers and doesn't match the per-pair vector-store namespaces. Instead the workspace loadout's search_memory/get_peer_card take observer/observed as tool arguments, delegate to the existing pair handlers via a handler_resolver seam on create_tool_executor, and results carry [observer->observed] attribution so multi-pair turns don't conflate.
  • Session scoping: optional session_id narrows message tools to one session. The scope read option from the scopes work (Scopes Phase 2b: scope option on chat, representation, context, and search #897) has a marked seam in WorkspaceChatOptions and lands as a follow-up once the scopes facade merges.
  • SDKs: Python Honcho.chat / chat_stream (+ HonchoAio mirrors), TypeScript honcho.chat / chatStream. SSE streaming and response_format structured output supported, mirroring peer.chat.

Salvaged from #373 (co-authored)

crud get_workspace_stats/get_active_peers, workspace tool JSON defs, workspace system prompt, format_documents_with_attribution, test suite + unified test cases, docs page, TS SDK surface. #373's temporal-visibility fix is not needed — main already gates by session membership windows (crud/message.py).

Verification

  • tests/test_workspace_chat.py: 46/46 (route, orchestrator preflight session-release, tool handlers, executor routing, attribution formatting)
  • Full suite: 1699 passed; only failures are tests/crud/test_document.py dedup tests that fail identically on clean main (pre-existing flake) — TS SDK build+typecheck pass
  • Live e2e on a local rig (2 peers, 26 msgs, haiku-4.5): single-peer, cross-peer, unanswerable, session-scoped, and streaming all answer correctly through the new Python SDK methods
  • Latency (local, embeddings disabled so memory is message-search only): prefetch 7–11ms; session-scoped answers 1.1–1.3s single model roundtrip; workspace-routing questions 5.6–11.5s (multi-turn message-search spiral — the known embedding-less-rig artifact; embedded rigs resolve in fewer turns per the .chat latency study)

Notes

  • Endpoint auth mirrors search_workspace (require_auth(workspace_name="workspace_id")); Prometheus record_dialectic_call wired; Langfuse trace name workspace_chat, telemetry agent_type workspace_dialectic.
  • Known pre-existing limitation (not this PR): conclusions require an OpenAI/Gemini embedding transport, so anthropic-only rigs run with inert observation memory — workspace chat degrades to message search there, same as peer chat.

🤖 Generated with Claude Code

POST /v3/workspaces/{workspace_id}/chat: agentic dialectic over the whole
workspace instead of a single (observer, observed) pair. Salvaged from
#373 and re-grown on today's DialecticAgent:

- WorkspaceDialecticAgent subclasses DialecticAgent via four new seams
  (_get_tools, _create_tool_executor, _prefetch_intro, _trace_name) instead
  of a base-class extraction; observer/observed use empty-string sentinels.
- Routing-accelerated prefetch: workspace stats + top-5 active peers with
  their self peer-cards (pure DB, ~7ms measured) so routing-obvious queries
  resolve without a discovery tool round.
- Observation search stays pair-scoped (matches per-pair vector namespaces;
  avoids workspace-flat top-k dilution): search_memory/get_peer_card take
  observer/observed as tool arguments, with pair attribution in results.
- workspace_chat / workspace_chat_stream orchestrators, WorkspaceChatOptions
  schema (scope param seam left for the #897 scopes facade), SSE streaming,
  structured output via response_format.
- crud: get_workspace_stats, get_active_peers; format_documents_with_attribution.
- SDKs: Python Honcho.chat/chat_stream + HonchoAio mirrors; TypeScript
  honcho.chat/chatStream.
- 46 tests (route, orchestrator preflight, tool handlers, executor routing,
  attribution formatting) + unified test cases + docs.

Co-Authored-By: doria <93405247+dr-frmr@users.noreply.github.com>
Co-Authored-By: Benjamin McCormick <docterformer@protonmail.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fbc7522b-d3e6-41be-a8c7-16b63927a0aa

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch adavya/dev-1326

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@adavyas adavyas changed the title Add workspace-level chat (DEV-1326) feat: Add workspace-level chat Jul 23, 2026
adavyas and others added 3 commits July 24, 2026 11:37
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nWarnings)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Restores docs/v3/documentation/features/chat.mdx to main's version. This
also puts back the peer-chat Structured Outputs section (#896) that the
workspace-chat commit removed as a rebase artifact.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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