Skip to content

Conversation

ashwin-ant
Copy link
Collaborator

@ashwin-ant ashwin-ant commented Sep 26, 2025

Summary

  • Add support for custom agent definitions via agents option
  • Add support for controlling setting sources via setting_sources option
  • Add /commit slash command to project
  • Add examples demonstrating both features
  • Add e2e tests for verification

Changes

Core Implementation

  • Add AgentDefinition and SettingSource types to types.py
  • Add agents and setting_sources fields to ClaudeCodeOptions
  • Update subprocess CLI transport to pass --agents and --setting-sources flags
  • Default behavior: When setting_sources is not provided, pass empty string (no settings loaded)
  • Handle empty setting_sources array correctly (pass empty string to CLI)

Examples

  • examples/agents.py: Demonstrates custom agent definitions with different tools and models
  • examples/setting_sources.py: Shows how setting sources control which settings are loaded
    • Default behavior (no settings)
    • User-only settings
    • User + project settings

Tests

  • Add e2e tests verifying agents and setting_sources functionality
  • Test default behavior (no settings loaded)
  • Test filtering by setting source
  • Use output_style checking to verify settings loaded/not loaded
  • Tests use temporary directories for isolated testing

Project Config

  • Add .claude/commands/commit.md slash command for git commits

Test Plan

  • E2E tests added for all new functionality
  • CI tests pass
  • Examples run successfully

🤖 Generated with Claude Code

ashwin-ant and others added 5 commits September 25, 2025 09:56
Add support for custom agent definitions and setting sources control,
matching the TypeScript SDK implementation.

- Add AgentDefinition type with description, prompt, tools, and model
- Add SettingSource type for controlling which settings to load
- Update ClaudeCodeOptions with agents and setting_sources fields
- Pass --agents and --setting-sources flags to CLI subprocess
- Add agents.py example demonstrating custom agent usage

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Add example demonstrating how setting_sources controls which settings
are loaded (user, project, local) and affects available slash commands.

- Add setting_sources.py example with three scenarios
- Fix subprocess_cli to handle empty setting_sources array (pass empty string)
- Example shows how project commands are excluded/included based on sources

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Add end-to-end tests verifying agents and setting_sources functionality
with real CLI interactions.

- Test custom agent definitions are passed through
- Test setting_sources=["user"] excludes project settings
- Test setting_sources=["user", "project"] includes project settings
- Use temporary directories for isolated testing

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Change default behavior to match TypeScript SDK - when setting_sources
is not provided, pass empty string to disable all settings loading.

- Always pass --setting-sources flag (empty string when None)
- Update examples to show default behavior (no settings)
- Update e2e tests to verify default behavior and use output_style checking

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@ashwin-ant ashwin-ant changed the title Ashwin/agentssettingsource feat: add agents and setting sources support Sep 26, 2025
@ashwin-ant ashwin-ant requested a review from a team September 26, 2025 05:56
dicksontsai
dicksontsai previously approved these changes Sep 26, 2025
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea to leave an example like /commit in this repo.

@ashwin-ant ashwin-ant merged commit 507e22c into main Sep 26, 2025
16 checks passed
@ashwin-ant ashwin-ant deleted the ashwin/agentssettingsource branch September 26, 2025 19:52
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.

2 participants