Skip to content

Commit 77a07aa

Browse files
committed
docs(showcase/agno): region markers across 12 cells
Bring agno to feature parity with the langgraph-python reference for shell-docs region markers. Round 5 of the per-framework sweep (mastra CopilotKit#4326, smalls batch CopilotKit#4361, ms-agent CopilotKit#4363, google-adk CopilotKit#4369). Cells advanced (12): - agentic-chat: sibling chat-component.snippet.tsx (chat-component, configure-suggestions, provider-setup) — production page.tsx mixes unrelated frontend tools / agent context for QA. - chat-customization-css: in-place css-variables in theme.css, theme-css-import in page.tsx. - chat-slots: in-place register-welcome-slot, register-disclaimer-slot, register-assistant-message-slot in page.tsx. - headless-simple: in-place use-agent-simple, message-list-simple in page.tsx. - prebuilt-popup: in-place popup-basic-setup in page.tsx. - prebuilt-sidebar: in-place sidebar-basic-setup, sidebar-configuration in page.tsx. - readonly-state-agent-context: in-place context-provider-sketch, use-agent-context-call in page.tsx. - shared-state-read-write: in-place use-agent-read, use-agent-write in page.tsx; preferences-card-render in preferences-card.tsx; notes-card-render in notes-card.tsx. - subagents: in-place delegation-log-frontend in delegation-log.tsx; subagent-setup, supervisor-delegation-tools in agents/subagents.py. - tool-rendering: sibling render-flight-tool.snippet.tsx with render-weather-tool, render-flight-tool, catchall-renderer; in-place weather-tool-backend on get_weather in agents/main.py — the docs page teaches per-tool + catchall patterns the production page.tsx doesn't exercise (weather-only render, shared god-file backend). - tool-rendering-custom-catchall: in-place use-default-render-tool-wildcard in page.tsx. - tool-rendering-default-catchall: in-place default-catchall-zero-config in page.tsx. Manifest: no changes — sibling .snippet.tsx files are picked up by the demo-content bundler walking the demo folder, no explicit highlight needed. Verification: re-ran the audit script; missing-region count for agno dropped from 12 cells → 0.
1 parent 98972ab commit 77a07aa

17 files changed

Lines changed: 249 additions & 0 deletions

File tree

showcase/integrations/agno/src/agents/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
load_dotenv()
2121

2222

23+
# @region[weather-tool-backend]
2324
@tool
2425
def get_weather(location: str):
2526
"""
@@ -32,6 +33,7 @@ def get_weather(location: str):
3233
str: Weather data as JSON.
3334
"""
3435
return json.dumps(get_weather_impl(location))
36+
# @endregion[weather-tool-backend]
3537

3638

3739
@tool

showcase/integrations/agno/src/agents/subagents.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
_SUB_MODEL_ID = "gpt-4o-mini"
3838

3939

40+
# @region[subagent-setup]
41+
# Each sub-agent is a full Agno `Agent(...)` with its own system prompt.
42+
# They don't share memory or tools with the supervisor — the supervisor
43+
# only sees their final text response, which is returned via the
44+
# delegation tool below.
4045
_research_agent = Agent(
4146
model=OpenAIChat(id=_SUB_MODEL_ID, timeout=120),
4247
description="Research sub-agent.",
@@ -64,6 +69,7 @@
6469
"2-3 crisp, actionable critiques. No preamble."
6570
),
6671
)
72+
# @endregion[subagent-setup]
6773

6874

6975
def _invoke_sub_agent(sub_agent: Agent, task: str) -> str:
@@ -182,6 +188,12 @@ def _delegate(
182188
# ---------------------------------------------------------------------------
183189

184190

191+
# @region[supervisor-delegation-tools]
192+
# Each function is a tool exposed to the supervisor agent. The supervisor
193+
# LLM "calls" these to delegate work; each call synchronously runs the
194+
# matching sub-agent, records the delegation into shared state, and
195+
# returns the sub-agent's output as the tool result the supervisor reads
196+
# on its next step.
185197
def research_agent(run_context: RunContext, task: str) -> dict[str, Any]:
186198
"""Delegate a research task to the research sub-agent.
187199
@@ -224,6 +236,7 @@ def critique_agent(run_context: RunContext, task: str) -> dict[str, Any]:
224236
sub_agent=_critique_agent,
225237
task=task,
226238
)
239+
# @endregion[supervisor-delegation-tools]
227240

228241

229242
# ---------------------------------------------------------------------------
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Docs-only snippet — not imported or rendered. The actual route is served
2+
// by page.tsx, which carries QA hooks (frontend tools, render tools, agent
3+
// context) that aren't relevant to the prebuilt-chat docs page. This file
4+
// gives the docs a minimal Chat definition to point at via the
5+
// chat-component / configure-suggestions / provider-setup regions without
6+
// disturbing the runtime demo.
7+
//
8+
// Why a sibling file: the bundler walks every file in the demo folder and
9+
// extracts region markers from each, so a docs-targeted teaching example
10+
// can live alongside the production demo without being wired into the
11+
// route. See: showcase/scripts/bundle-demo-content.ts.
12+
13+
import { CopilotKit } from "@copilotkit/react-core";
14+
import {
15+
CopilotChat,
16+
useConfigureSuggestions,
17+
} from "@copilotkit/react-core/v2";
18+
19+
// @region[chat-component]
20+
function Chat() {
21+
// @region[configure-suggestions]
22+
useConfigureSuggestions({
23+
suggestions: [
24+
{ title: "Write a sonnet", message: "Write a short sonnet about AI." },
25+
],
26+
available: "always",
27+
});
28+
// @endregion[configure-suggestions]
29+
30+
return <CopilotChat agentId="agentic_chat" className="h-full rounded-2xl" />;
31+
}
32+
// @endregion[chat-component]
33+
34+
export function AgenticChatPage() {
35+
return (
36+
// @region[provider-setup]
37+
<CopilotKit runtimeUrl="/api/copilotkit" agent="agentic_chat">
38+
<div className="flex justify-center items-center h-screen w-full">
39+
<div className="h-full w-full max-w-4xl">
40+
<Chat />
41+
</div>
42+
</div>
43+
</CopilotKit>
44+
// @endregion[provider-setup]
45+
);
46+
}

showcase/integrations/agno/src/app/demos/chat-customization-css/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import React from "react";
88
import { CopilotKit } from "@copilotkit/react-core";
99
import { CopilotChat } from "@copilotkit/react-core/v2";
10+
// @region[theme-css-import]
1011
import "./theme.css";
12+
// @endregion[theme-css-import]
1113

1214
export default function ChatCustomizationCssDemo() {
1315
return (

showcase/integrations/agno/src/app/demos/chat-customization-css/theme.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* leak out and affect the rest of the showcase app.
44
*/
55

6+
/* @region[css-variables] */
67
/* CopilotKit CSS variable overrides (accent colors, etc.) */
78
.chat-css-demo-scope {
89
--copilot-kit-primary-color: #ff006e;
@@ -14,6 +15,7 @@
1415
--copilot-kit-separator-color: #ff006e;
1516
--copilot-kit-muted-color: #c2185b;
1617
}
18+
/* @endregion[css-variables] */
1719

1820
/* Messages container */
1921
.chat-css-demo-scope .copilotKitMessages {

showcase/integrations/agno/src/app/demos/chat-slots/page.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@ function Chat() {
3333
available: "always",
3434
});
3535

36+
// @region[register-welcome-slot]
3637
const welcomeScreen = CustomWelcomeScreen;
38+
// @endregion[register-welcome-slot]
39+
// @region[register-disclaimer-slot]
3740
const input = { disclaimer: CustomDisclaimer };
41+
// @endregion[register-disclaimer-slot]
42+
// @region[register-assistant-message-slot]
3843
const messageView = {
3944
assistantMessage:
4045
CustomAssistantMessage as unknown as typeof CopilotChatAssistantMessage,
4146
};
47+
// @endregion[register-assistant-message-slot]
4248

4349
return (
4450
<CopilotChat

showcase/integrations/agno/src/app/demos/headless-simple/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function ShowCard({ title, body }: { title: string; body: string }) {
3434
}
3535

3636
function HeadlessChat() {
37+
// @region[use-agent-simple]
3738
const { agent } = useAgent({ agentId: "headless-simple" });
3839
const { copilotkit } = useCopilotKit();
3940
const [input, setInput] = useState("");
@@ -49,6 +50,7 @@ function HeadlessChat() {
4950
});
5051

5152
const renderToolCall = useRenderToolCall();
53+
// @endregion[use-agent-simple]
5254

5355
const send = () => {
5456
const text = input.trim();
@@ -66,6 +68,7 @@ function HeadlessChat() {
6668
<div className="flex flex-col gap-3">
6769
<h1 className="text-xl font-semibold">Headless Chat (Simple)</h1>
6870
<div className="flex flex-col gap-2 rounded-xl border border-gray-200 bg-white p-4 min-h-[300px]">
71+
{/* @region[message-list-simple] */}
6972
{agent.messages.length === 0 && (
7073
<div className="text-sm text-gray-400">No messages yet. Say hi!</div>
7174
)}
@@ -106,6 +109,7 @@ function HeadlessChat() {
106109
{agent.isRunning && (
107110
<div className="text-xs text-gray-400">Agent is thinking...</div>
108111
)}
112+
{/* @endregion[message-list-simple] */}
109113
</div>
110114
<div className="flex gap-2">
111115
<textarea

showcase/integrations/agno/src/app/demos/prebuilt-popup/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
// Outer layer — provider + main content + floating popup launcher.
1111
export default function PrebuiltPopupDemo() {
1212
return (
13+
// @region[popup-basic-setup]
1314
<CopilotKit runtimeUrl="/api/copilotkit" agent="prebuilt-popup">
1415
<MainContent />
1516
<CopilotPopup
@@ -21,6 +22,7 @@ export default function PrebuiltPopupDemo() {
2122
/>
2223
<Suggestions />
2324
</CopilotKit>
25+
// @endregion[popup-basic-setup]
2426
);
2527
}
2628

showcase/integrations/agno/src/app/demos/prebuilt-sidebar/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ import {
1010
// Outer layer — provider + main content + sidebar.
1111
export default function PrebuiltSidebarDemo() {
1212
return (
13+
// @region[sidebar-basic-setup]
1314
<CopilotKit runtimeUrl="/api/copilotkit" agent="prebuilt-sidebar">
1415
<MainContent />
16+
{/* @region[sidebar-configuration] */}
1517
<CopilotSidebar agentId="prebuilt-sidebar" defaultOpen={true} />
18+
{/* @endregion[sidebar-configuration] */}
1619
<Suggestions />
1720
</CopilotKit>
21+
// @endregion[sidebar-basic-setup]
1822
);
1923
}
2024

showcase/integrations/agno/src/app/demos/readonly-state-agent-context/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ const ACTIVITIES = [
3737
];
3838

3939
function DemoContent() {
40+
// @region[context-provider-sketch]
4041
const [userName, setUserName] = useState("Atai");
4142
const [userTimezone, setUserTimezone] = useState("America/Los_Angeles");
4243
const [recentActivity, setRecentActivity] = useState<string[]>([
4344
ACTIVITIES[0],
4445
ACTIVITIES[2],
4546
]);
47+
// @endregion[context-provider-sketch]
4648

49+
// @region[use-agent-context-call]
4750
useAgentContext({
4851
description: "The currently logged-in user's display name",
4952
value: userName,
@@ -56,6 +59,7 @@ function DemoContent() {
5659
description: "The user's recent activity in the app, newest first",
5760
value: recentActivity,
5861
});
62+
// @endregion[use-agent-context-call]
5963

6064
useConfigureSuggestions({
6165
suggestions: [

0 commit comments

Comments
 (0)