Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .cursor/rules/core-modules.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ alwaysApply: true
- All calls to `GlobalConfig()` return the same instance
- Loads from YAML files via `from_yaml()` method
- Loads from environment variables via `pydantic-settings` (prefix `SGR__`)
- Contains: `llm`, `search`, `execution`, `prompts`, `mcp`, `agents`, `tools`
- Contains: `llm`, `execution`, `prompts`, `mcp`, `agents`, `tools`
- `agents`: Dictionary of `AgentDefinition` instances by name
- `tools`: Dictionary of tool definitions by name
- `definitions_from_yaml()`: Loads agent definitions from YAML (merges with existing)
Expand All @@ -71,14 +71,15 @@ alwaysApply: true
- Inherits from `AgentConfig` (has all config fields)
- Additional fields: `name`, `base_class`, `tools`
- `base_class`: Can be class, ImportString (e.g., `"sgr_agent_core.agents.SGRAgent"`), or registry name
- `tools`: List of tool names (strings) or tool classes
- `tools`: List of `ToolDefinition` objects (resolved from names, classes, or dicts)
- Supports YAML loading via `GlobalConfig.definitions_from_yaml()`
- Validates import strings point to existing files
- Automatically merges with `GlobalConfig` defaults
- Automatically merges with `GlobalConfig` defaults (tools: global kwargs merged with agent-level kwargs)

### AgentConfig (`sgr_agent_core/agent_definition.py`)
- Runtime configuration for agent instance
- Combines: `LLMConfig`, `SearchConfig`, `ExecutionConfig`, `PromptsConfig`, `MCPConfig`
- Combines: `LLMConfig`, `ExecutionConfig`, `PromptsConfig`, `MCPConfig`
- Note: Search settings (`tavily_api_key`, `max_results`, etc.) are NOT in `AgentConfig`; they are configured per-tool in the `tools:` section as `SearchConfig` kwargs
- Supports hierarchical inheritance from `GlobalConfig`
- Uses `extra="allow"` to support custom fields for agent-specific parameters

Expand Down
35 changes: 19 additions & 16 deletions docs/en/framework/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ tools:
Each item in the `tools` list can be:

- **String** – tool name (resolved from the `tools:` section or `ToolRegistry`)
- **Object** – dict with required `"name"` and optional parameters passed to the tool at runtime as kwargs (e.g. search settings for search tools)
- **Object** – compact dict `{tool_name: {kwargs}}` or `{tool_name: null}` with optional kwargs overriding global tool config

```yaml
agents:
Expand All @@ -115,16 +115,16 @@ agents:
tools:
- "web_search_tool"
- "reasoning_tool"
# Per-tool config: name + kwargs (e.g. search settings)
- name: "extract_page_content_tool"
content_limit: 2000
- name: "web_search_tool"
max_results: 15
max_searches: 6
# tavily_api_key, max_searches, etc. can be set here instead of in global search:
# Per-tool config override: {tool_name: {kwargs}}
- extract_page_content_tool:
content_limit: 2000
- web_search_tool:
max_results: 15
max_searches: 6
# tavily_api_key and other settings can be set here or globally in tools:
```

Search-related settings (`tavily_api_key`, `tavily_api_base_url`, `max_results`, `content_limit`, `max_searches`) can be set globally in `search:` or per-tool in the tool object. Tool kwargs override agent-level `search` for that tool.
Search-related settings (`tavily_api_key`, `tavily_api_base_url`, `max_results`, `content_limit`, `max_searches`) are configured per-tool in the `tools:` section (global defaults) or overridden per-agent in the `tools` list.

!!! note "Tool Resolution Order"
When resolving tools, the system checks in this order:
Expand Down Expand Up @@ -178,6 +178,16 @@ In this example, the `simple_agent` uses:
An agent with full parameter override:

```yaml
# Search tool settings are configured globally in tools: section
tools:
web_search_tool:
tavily_api_key: "your-tavily-api-key"
max_results: 15
max_searches: 6
extract_page_content_tool:
tavily_api_key: "your-tavily-api-key"
content_limit: 2000

agents:
custom_research_agent:
base_class: "sgr_agent_core.agents.sgr_agent.ResearchSGRAgent"
Expand All @@ -189,17 +199,10 @@ agents:
max_tokens: 16000
# api_key and base_url are inherited from GlobalConfig

# Override search settings
search:
max_results: 15
max_searches: 6
content_limit: 2000

# Override execution settings
execution:
max_iterations: 15
max_clarifications: 5
max_searches: 6
streaming_generator: "openai" # default; use "open_webui" for Open WebUI UI
logs_dir: "logs/custom_agent"
reports_dir: "reports/custom_agent"
Expand Down
25 changes: 7 additions & 18 deletions docs/en/framework/first-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,12 @@ tools:
**agents.yaml**

```yaml
# Tool Definitions (optional, can also be in config.yaml)
# Search tool settings are configured in tools: section (not in agent-level search:)
tools:
# Tools can be defined here or in config.yaml
# If not defined, tools are resolved from ToolRegistry by name
web_search_tool:
tavily_api_key: "___"
max_results: 5
content_limit: 5000

agents:
simple_search_agent:
Expand All @@ -244,11 +246,6 @@ agents:
tools:
- "web_search_tool" # Recommended: snake_case format
- "final_answer_tool" # Recommended: snake_case format
# - "custom_tool" # From tools section (if defined)
search:
tavily_api_key: "___"
max_results: 5
content_limit: 5000

writer_agent:
base_class: "SGRToolCallingAgent"
Expand Down Expand Up @@ -313,13 +310,6 @@ if __name__ == "__main__":
"temperature": 0.2,
"proxy": null
},
"search": {
"tavily_api_key": "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",
"tavily_api_base_url": "https://api.tavily.com",
"max_searches": 4,
"max_results": 5,
"content_limit": 5000
},
"execution": {
"max_clarifications": 3,
"max_iterations": 7,
Expand All @@ -344,8 +334,8 @@ if __name__ == "__main__":
"name": "simple_search_agent",
"base_class": "ResearchSGRToolCallingAgent",
"tools": [
"WebSearchTool",
"FinalAnswerTool"
{"name": "web_search_tool", "tavily_api_key": "***", "max_results": 5, "content_limit": 5000},
{"name": "final_answer_tool"}
]
}
```
Expand All @@ -361,7 +351,6 @@ if __name__ == "__main__":
"temperature": 0.8,
"proxy": null
},
"search": null,
"execution": {
"max_clarifications": 3,
"max_iterations": 7,
Expand Down
53 changes: 35 additions & 18 deletions docs/en/framework/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,24 +348,30 @@ Use for finding up-to-date information, verifying facts, researching current eve

**Configuration:**

Search settings are configured per-tool in the `tools:` section (not in a global `search:` block):

```yaml
search:
tavily_api_key: "your-tavily-api-key" # Required: Tavily API key
tavily_api_base_url: "https://api.tavily.com" # Tavily API URL
max_searches: 4 # Maximum number of search operations
max_results: 10 # Maximum results in search query (overrides tool's max_results if lower)
tools:
web_search_tool:
tavily_api_key: "your-tavily-api-key" # Required: Tavily API key
tavily_api_base_url: "https://api.tavily.com" # Tavily API URL
max_searches: 4 # Maximum number of search operations
max_results: 10 # Maximum results in search query (overrides tool's max_results if lower)
```

After reaching `max_searches`, the tool is automatically removed from available tools.

**Example:**

```yaml
tools:
web_search_tool:
tavily_api_key: "your-tavily-api-key"
max_searches: 6
max_results: 15

agents:
research_agent:
search:
max_searches: 6
max_results: 15
tools:
- "web_search_tool"
```
Expand Down Expand Up @@ -401,20 +407,26 @@ Call after `web_search_tool` to get detailed information from promising URLs fou

**Configuration:**

Search settings are configured per-tool in the `tools:` section:

```yaml
search:
tavily_api_key: "your-tavily-api-key" # Required: Tavily API key
tavily_api_base_url: "https://api.tavily.com" # Tavily API URL
content_limit: 1500 # Content character limit per source (truncates extracted content)
tools:
extract_page_content_tool:
tavily_api_key: "your-tavily-api-key" # Required: Tavily API key
tavily_api_base_url: "https://api.tavily.com" # Tavily API URL
content_limit: 1500 # Content character limit per source (truncates extracted content)
```

**Example:**

```yaml
tools:
extract_page_content_tool:
tavily_api_key: "your-tavily-api-key"
content_limit: 2000 # Increase content limit for more detailed extraction

agents:
research_agent:
search:
content_limit: 2000 # Increase content limit for more detailed extraction
tools:
- "web_search_tool"
- "extract_page_content_tool"
Expand All @@ -436,6 +448,15 @@ Tools are configured per agent in the `agents.yaml` file or agent definitions. Y
**Example: Basic Tool Configuration**

```yaml
tools:
web_search_tool:
tavily_api_key: "your-tavily-api-key"
max_searches: 4
max_results: 10
extract_page_content_tool:
tavily_api_key: "your-tavily-api-key"
content_limit: 1500

agents:
my_agent:
base_class: "SGRAgent"
Expand All @@ -450,10 +471,6 @@ agents:
execution:
max_clarifications: 3
max_iterations: 10
search:
max_searches: 4
max_results: 10
content_limit: 1500
```

### Defining Tools in Configuration
Expand Down
35 changes: 19 additions & 16 deletions docs/ru/framework/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ tools:
Каждый элемент списка `tools` может быть:

- **Строка** — имя инструмента (резолвится из секции `tools:` или `ToolRegistry`)
- **Объект** — словарь с обязательным полем `"name"` и необязательными параметрами, передаваемыми в инструмент при вызове (например, настройки поиска)
- **Объект** — компактный формат `{tool_name: {kwargs}}` или `{tool_name: null}` с необязательными kwargs, переопределяющими глобальный конфиг тула

```yaml
agents:
Expand All @@ -118,16 +118,16 @@ agents:
tools:
- "web_search_tool"
- "reasoning_tool"
# Конфиг по инструменту: name + kwargs (например, настройки поиска)
- name: "extract_page_content_tool"
content_limit: 2000
- name: "web_search_tool"
max_results: 15
max_searches: 6
# tavily_api_key, max_searches и т.д. можно задать здесь вместо глобального search:
# Конфиг по инструменту: {tool_name: {kwargs}}
- extract_page_content_tool:
content_limit: 2000
- web_search_tool:
max_results: 15
max_searches: 6
# tavily_api_key и другие настройки можно задать здесь или глобально в tools:
```

Настройки поиска (`tavily_api_key`, `tavily_api_base_url`, `max_results`, `content_limit`, `max_searches`) можно задавать глобально в `search:` или в объекте инструмента. kwargs инструмента переопределяют агентский `search` для этого инструмента.
Настройки поиска (`tavily_api_key`, `tavily_api_base_url`, `max_results`, `content_limit`, `max_searches`) задаются в секции `tools:` (глобальные значения по умолчанию) или переопределяются для агента в списке `tools`.

!!! note "Порядок резолва инструментов"
При резолве инструментов система проверяет в порядке:
Expand Down Expand Up @@ -179,6 +179,16 @@ agents:
Агент с полным переопределением параметров:

```yaml
# Настройки поисковых тулов задаются глобально в секции tools:
tools:
web_search_tool:
tavily_api_key: "your-tavily-api-key"
max_results: 15
max_searches: 6
extract_page_content_tool:
tavily_api_key: "your-tavily-api-key"
content_limit: 2000

agents:
custom_research_agent:
base_class: "sgr_agent_core.agents.sgr_agent.ResearchSGRAgent"
Expand All @@ -190,17 +200,10 @@ agents:
max_tokens: 16000
# api_key и base_url наследуются из GlobalConfig

# Переопределяем настройки поиска
search:
max_results: 15
max_searches: 6
content_limit: 2000

# Переопределяем настройки выполнения
execution:
max_iterations: 15
max_clarifications: 5
max_searches: 6
streaming_generator: "openai" # по умолчанию; "open_webui" для Open WebUI
logs_dir: "logs/custom_agent"
reports_dir: "reports/custom_agent"
Expand Down
22 changes: 8 additions & 14 deletions docs/ru/framework/first-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ execution:
**agents.yaml**

```yaml
tools:
web_search_tool:
tavily_api_key: "___"
max_results: 5
content_limit: 5000

agents:
simple_search_agent:
base_class: "ResearchSGRToolCallingAgent"
Expand All @@ -219,10 +225,6 @@ agents:
tools:
- "web_search_tool"
- "final_answer_tool"
search:
tavily_api_key: "___"
max_results: 5
content_limit: 5000

writer_agent:
base_class: "SGRToolCallingAgent"
Expand Down Expand Up @@ -282,13 +284,6 @@ if __name__ == "__main__":
"temperature": 0.2,
"proxy": null
},
"search": {
"tavily_api_key": "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",
"tavily_api_base_url": "https://api.tavily.com",
"max_searches": 4,
"max_results": 5,
"content_limit": 5000
},
"execution": {
"max_clarifications": 3,
"max_iterations": 7,
Expand All @@ -313,8 +308,8 @@ if __name__ == "__main__":
"name": "simple_search_agent",
"base_class": "ResearchSGRToolCallingAgent",
"tools": [
"WebSearchTool",
"FinalAnswerTool"
{"name": "web_search_tool", "tavily_api_key": "***", "max_results": 5, "content_limit": 5000},
{"name": "final_answer_tool"}
]
}
```
Expand All @@ -330,7 +325,6 @@ if __name__ == "__main__":
"temperature": 0.8,
"proxy": null
},
"search": null,
"execution": {
"max_clarifications": 3,
"max_iterations": 7,
Expand Down
Loading
Loading