|
11 | 11 |
|
12 | 12 | from ..agent import Agent
|
13 | 13 |
|
14 |
| -# JSON Schema for agent configuration |
15 |
| -AGENT_CONFIG_SCHEMA = { |
16 |
| - "$schema": "http://json-schema.org/draft-07/schema#", |
17 |
| - "title": "Agent Configuration", |
18 |
| - "description": "Configuration schema for creating agents", |
19 |
| - "type": "object", |
20 |
| - "properties": { |
21 |
| - "name": { |
22 |
| - "description": "Name of the agent", |
23 |
| - "type": ["string", "null"], |
24 |
| - "default": None |
25 |
| - }, |
26 |
| - "model": { |
27 |
| - "description": "The model ID to use for this agent. If not specified, uses the default model.", |
28 |
| - "type": ["string", "null"], |
29 |
| - "default": None |
30 |
| - }, |
31 |
| - "prompt": { |
32 |
| - "description": "The system prompt for the agent. Provides high level context to the agent.", |
33 |
| - "type": ["string", "null"], |
34 |
| - "default": None |
35 |
| - }, |
36 |
| - "tools": { |
37 |
| - "description": "List of tools the agent can use. Can be module paths, file paths, or tool names.", |
38 |
| - "type": "array", |
39 |
| - "items": { |
40 |
| - "type": "string" |
41 |
| - }, |
42 |
| - "default": [] |
43 |
| - } |
44 |
| - }, |
45 |
| - "additionalProperties": False |
46 |
| -} |
| 14 | + |
| 15 | +def _load_schema() -> dict: |
| 16 | + """Load the agent configuration schema from file.""" |
| 17 | + schema_path = Path(__file__).parent / "schemas" / "agent-config-v1.json" |
| 18 | + with open(schema_path, 'r') as f: |
| 19 | + return json.load(f) |
47 | 20 |
|
48 | 21 |
|
49 | 22 | def config_to_agent(config: str | dict[str, any], **kwargs) -> Agent:
|
@@ -95,7 +68,8 @@ def config_to_agent(config: str | dict[str, any], **kwargs) -> Agent:
|
95 | 68 |
|
96 | 69 | # Validate configuration against schema
|
97 | 70 | try:
|
98 |
| - jsonschema.validate(config_dict, AGENT_CONFIG_SCHEMA) |
| 71 | + schema = _load_schema() |
| 72 | + jsonschema.validate(config_dict, schema) |
99 | 73 | except ValidationError as e:
|
100 | 74 | # Provide more detailed error message
|
101 | 75 | error_path = " -> ".join(str(p) for p in e.absolute_path) if e.absolute_path else "root"
|
|
0 commit comments