Skip to content

Commit ba29cb5

Browse files
costiashclaude
andauthored
feat(claude-agent-sdk): enhance tutorials with improved notebooks, agents, and documentation (anthropics#312)
* feat(agent-sdk): enhance notebooks, agents, and add documentation Improvements to the Claude Agent SDK tutorial notebooks: - Enhanced 00_The_one_liner_research_agent.ipynb with richer outputs - Enhanced 02_The_observability_agent.ipynb with better visualization - Improved research_agent/agent.py with cleaner code structure - Improved observability_agent/agent.py with enhanced features - Refactored utils/agent_visualizer.py for better maintainability - Added utils/html_renderer.py for rich HTML visualization in Jupyter - Added docs/README.md - Documentation overview - Added docs/ADDITIONS.md - Summary of enhancements - Added docs/CODEBASE_OVERVIEW.md - Architecture guide - Added docs/TROUBLESHOOTING.md - Common issues and solutions - Added pyyaml to pyproject.toml 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * feat(agent-sdk): add enhanced 01_The_chief_of_staff_agent.ipynb Include the improved chief of staff notebook with cleaner outputs and examples. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * feat(agent-sdk): add enhanced chief_of_staff_agent implementation Updates to the chief of staff agent: - Improved agent.py with cleaner code structure - Updated CLAUDE.md with better context - Enhanced slash commands (budget-impact, strategic-brief, talent-scan) - Improved decision_matrix.py script 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix(claude-agent-sdk): address PR anthropics#312 review feedback Addresses all feedback from @PedramNavid's review. ## Critical Issues Fixed - [x] Run `ruff format` and `ruff check` - all 15 Python files pass - [x] Uncomment `%pip install` in 00_The_one_liner_research_agent.ipynb - [x] Remove supplementary docs/ directory per repo guidelines - Deleted: ADDITIONS.md, CODEBASE_OVERVIEW.md, TROUBLESHOOTING.md, README.md - [x] Model names verified (claude-opus-4-5, claude-sonnet-4-5 are valid aliases) ## Important Issues Addressed - [x] sys.path.insert() hack already removed from research_agent/agent.py - [x] Verified dependencies: kept pandas/markdown (used by html_renderer.py), removed unused numpy and pandas-stubs - [x] Thread-safety warning already present in agent_visualizer.py (lines 106-111) - [x] docs/ references now removed (files deleted) ## Suggestions Implemented - [x] escape=True already added for DataFrame HTML (html_renderer.py:207,221) - [x] type: ignore already fixed with proper TypedDict in decision_matrix.py - [x] Docstring examples already present in agent_visualizer.py - [x] Consistent type hints across all agent modules ## Additional Cleanup - Removed unrelated files: GEMINI.md, permission-flow-diagram.md - Removed temporary directories: .vscode/, plans/, extra output reports - Cleaned pyproject.toml: removed dev dependencies (mypy, ruff, pytest), testing config, and unused numpy dependency ## Code Quality Verification - All Python files pass `ruff check` - All Python files pass `ruff format --check` - All agent modules pass mypy type checking - Project structure now matches upstream exactly --------- Co-authored-by: Claude <[email protected]>
1 parent b4a8aae commit ba29cb5

23 files changed

+6318
-714
lines changed

claude_agent_sdk/00_The_one_liner_research_agent.ipynb

Lines changed: 1015 additions & 214 deletions
Large diffs are not rendered by default.

claude_agent_sdk/01_The_chief_of_staff_agent.ipynb

Lines changed: 2203 additions & 146 deletions
Large diffs are not rendered by default.

claude_agent_sdk/02_The_observability_agent.ipynb

Lines changed: 1368 additions & 97 deletions
Large diffs are not rendered by default.

claude_agent_sdk/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ Each notebook includes an agent implementation in its respective directory:
9494
- **`chief_of_staff_agent/`** - Multi-agent executive assistant with financial modeling and compliance
9595
- **`observability_agent/`** - DevOps monitoring agent with GitHub integration
9696

97+
**Running standalone agents:** To import agent modules outside of notebooks, either run from the `claude_agent_sdk/` directory or install the package in editable mode:
98+
```bash
99+
uv pip install -e .
100+
```
101+
97102
## Background
98103
### The Evolution of Claude Agent SDK
99104

claude_agent_sdk/chief_of_staff_agent/.claude/commands/budget-impact.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: budget-impact
33
description: Analyze the financial impact of a decision on budget, burn rate, and runway
44
---
55

6-
Use the financial-analyst subagent to analyze the budget impact of: {{args}}
6+
Use the financial-analyst subagent to analyze the budget impact of: $ARGUMENTS
77

88
Provide a comprehensive analysis including:
99
1. Total cost (one-time and recurring)

claude_agent_sdk/chief_of_staff_agent/.claude/commands/slash-command-test.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ name: slash-command-test
33
description: example of how a slash-command works
44
---
55

6-
Reverse the following sentence word wise: {{args}}
6+
Reverse the following sentence word wise: $ARGUMENTS

claude_agent_sdk/chief_of_staff_agent/.claude/commands/strategic-brief.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: strategic-brief
33
description: Generate a comprehensive strategic brief by coordinating analysis from both financial and talent perspectives
44
---
55

6-
Create a strategic brief on: {{args}}
6+
Create a strategic brief on: $ARGUMENTS
77

88
Coordinate with both the financial-analyst and recruiter subagents to provide:
99

claude_agent_sdk/chief_of_staff_agent/.claude/commands/talent-scan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: talent-scan
33
description: Scan the talent market for specific roles and provide hiring recommendations
44
---
55

6-
Use the recruiter subagent to perform a talent market scan for: {{args}}
6+
Use the recruiter subagent to perform a talent market scan for: $ARGUMENTS
77

88
Analyze and report on:
99
1. Talent availability in target markets

claude_agent_sdk/chief_of_staff_agent/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- **HQ**: San Francisco, CA
99

1010
## Financial Snapshot
11-
- **Monthly Burn Rate**: $500,000
11+
- **Monthly Burn Rate**: ~$500,000
1212
- **Current Runway**: 20 months (until September 2025)
1313
- **ARR**: $2.4M (growing 15% MoM)
1414
- **Cash in Bank**: $10M

claude_agent_sdk/chief_of_staff_agent/agent.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
load_dotenv()
1616

1717

18-
def get_activity_text(msg) -> str | None:
18+
def get_activity_text(msg: Any) -> str | None:
1919
"""Extract activity text from a message"""
2020
try:
2121
if "Assistant" in msg.__class__.__name__:
@@ -31,7 +31,7 @@ def get_activity_text(msg) -> str | None:
3131
return None
3232

3333

34-
def print_activity(msg) -> None:
34+
def print_activity(msg: Any) -> None:
3535
"""Print activity to console"""
3636
activity = get_activity_text(msg)
3737
if activity:
@@ -78,27 +78,33 @@ async def send_query(
7878
"""
7979

8080
# build options with optional output style
81-
options_dict = {
82-
"model": "claude-sonnet-4-5",
83-
"allowed_tools": [
81+
settings = None
82+
if output_style:
83+
settings = json.dumps({"outputStyle": output_style})
84+
85+
options = ClaudeAgentOptions(
86+
model="claude-opus-4-5",
87+
allowed_tools=[
8488
"Task", # enables subagent delegation
8589
"Read",
8690
"Write",
8791
"Edit",
8892
"Bash",
8993
"WebSearch",
9094
],
91-
"continue_conversation": continue_conversation,
92-
"system_prompt": system_prompt,
93-
"permission_mode": permission_mode,
94-
"cwd": os.path.dirname(os.path.abspath(__file__)),
95-
}
96-
97-
# add output style if specified
98-
if output_style:
99-
options_dict["settings"] = json.dumps({"outputStyle": output_style})
100-
101-
options = ClaudeAgentOptions(**options_dict)
95+
continue_conversation=continue_conversation,
96+
system_prompt=system_prompt,
97+
permission_mode=permission_mode,
98+
cwd=os.path.dirname(os.path.abspath(__file__)),
99+
settings=settings,
100+
# IMPORTANT: setting_sources must include "project" to load filesystem settings:
101+
# - Slash commands from .claude/commands/
102+
# - CLAUDE.md project instructions
103+
# - Subagent definitions from .claude/agents/
104+
# - Hooks from .claude/settings.local.json
105+
# Without this, the SDK operates in isolation mode with no filesystem settings loaded.
106+
setting_sources=["project", "local"],
107+
)
102108

103109
result = None
104110
messages = [] # this is to append the messages ONLY for this agent turn

0 commit comments

Comments
 (0)