From e15123a9975e259f3bcd2de9ffeb76c33ee4e019 Mon Sep 17 00:00:00 2001 From: adavyas Date: Fri, 24 Jul 2026 16:02:27 -0400 Subject: [PATCH] docs: drop docs changes from this PR (defer to follow-up) 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 --- docs/v3/documentation/features/chat.mdx | 79 ++++++++++++------------- 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/docs/v3/documentation/features/chat.mdx b/docs/v3/documentation/features/chat.mdx index 83324b2e..6aab6996 100644 --- a/docs/v3/documentation/features/chat.mdx +++ b/docs/v3/documentation/features/chat.mdx @@ -94,6 +94,43 @@ for await (const chunk of responseStream.iter_text()) { Streaming is useful for displaying real-time responses in chat interfaces or when asking complex questions that require longer answers. +## Structured Outputs + +When your application needs a machine-readable answer instead of prose, pass a schema as `response_format` and the answer is guaranteed to conform to it: + + +```python Python +from pydantic import BaseModel + +class OnboardingStatus(BaseModel): + completed: bool + remaining_steps: list[str] + +status = peer.chat( + "Has the user completed the onboarding flow?", + response_format=OnboardingStatus, +) +# status is a parsed OnboardingStatus instance +``` + +```typescript TypeScript +import { z } from 'zod'; + +const OnboardingStatus = z.object({ + completed: z.boolean(), + remainingSteps: z.array(z.string()), +}); + +const status = await peer.chat( + "Has the user completed the onboarding flow?", + { responseFormat: OnboardingStatus }, +); +// status is typed as z.infer +``` + + +The agent runs its full reasoning loop either way — only the final answer is formatted to your schema. See [Structured Outputs](/v3/documentation/features/advanced/structured-outputs) for the supported schema subset, streaming behavior, and best practices. + ## Integration Patterns ### Dynamic Prompt Enhancement @@ -189,48 +226,6 @@ const goals = await peer.chat("What are the user's main goals or objectives?"); ``` -## Workspace-Level Chat - -While `peer.chat()` queries knowledge about a single peer, `honcho.chat()` searches across **all peers and observations** in the workspace. This is useful for cross-peer analysis, discovering common themes, or asking workspace-wide questions. - - -```python Python -from honcho import Honcho - -honcho = Honcho() - -# Ask about the entire workspace -answer = honcho.chat("What are common themes across all users?") -print(answer) - -# With streaming -stream = honcho.chat_stream("Summarize all peer activity this week.") -for chunk in stream: - print(chunk, end="", flush=True) - -# Async -answer = await honcho.aio.chat("Which users have discussed topic X?") -``` - -```typescript TypeScript -import { Honcho } from '@honcho-ai/sdk'; - -const honcho = new Honcho({}); - -// Ask about the entire workspace -const answer = await honcho.chat("What are common themes across all users?"); -console.log(answer); - -// With streaming -const stream = await honcho.chatStream("Summarize all peer activity this week."); -for await (const chunk of stream) { - process.stdout.write(chunk); -} -``` - - -Workspace chat accepts `reasoning_level` and optional `session` scoping. For streaming, use the separate `chat_stream()` / `chatStream()` method rather than a `stream` parameter. - ## How Honcho Answers When you call `peer.chat(query)`: