Skip to content

Commit 2ee8467

Browse files
jfrench9claude
andauthored
Add comprehensive agent management system with new APIs and models (#11)
## Summary This PR introduces a comprehensive agent management system by adding new agent-related APIs, enhancing existing models, and improving the overall agent interaction capabilities. The changes represent a significant expansion of the platform's agent functionality. ## Key Accomplishments ### New Agent APIs (6 new endpoints) - **Agent Selection & Discovery**: Added auto-selection and recommendation capabilities for intelligent agent matching - **Agent Management**: Introduced agent listing, metadata retrieval, and specific agent execution - **Batch Processing**: Added support for processing multiple agent queries simultaneously - **Enhanced Agent Interaction**: Replaced legacy financial agent query with more flexible execution system ### Enhanced Data Models - **Agent Models**: Added 15+ new model classes supporting agent metadata, recommendations, batch operations, and selection criteria - **Response Enhancement**: Expanded agent request/response models with better error handling, token usage tracking, and context support - **Credit System Updates**: Enhanced credit balance checking to accept flexible input types (string/float) - **Type Safety**: Improved type definitions across all models for better reliability ### Model Improvements - Enhanced existing models (auth, credits, schema, database) with additional attributes and better structure - Added support for agent modes and selection criteria - Improved consistency across model definitions ## Breaking Changes ⚠️ **Removed Legacy API**: The `query_financial_agent.py` endpoint has been removed and replaced with the new agent execution system. Users should migrate to the new agent APIs. ## Testing Notes - All new agent endpoints should be tested with various input scenarios - Batch processing functionality requires testing with multiple concurrent requests - Credit balance validation should be tested with both string and numeric inputs - Agent recommendation system should be validated with different selection criteria ## Infrastructure Considerations - The addition of 6 new API endpoints may impact rate limiting and load balancing configurations - Batch processing capabilities may require monitoring for resource usage patterns - New model classes expand the codebase significantly and may affect build times - Enhanced error handling and token tracking provide better observability for debugging This enhancement positions the platform for more sophisticated agent interactions while maintaining backward compatibility for most existing functionality. --- 🤖 Generated with [Claude Code](https://claude.ai/code) **Branch Info:** - Source: `feature/new-agents` - Target: `main` - Type: feature Co-Authored-By: Claude <noreply@anthropic.com>
2 parents 404b005 + 501ec4b commit 2ee8467

42 files changed

Lines changed: 3227 additions & 590 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
from http import HTTPStatus
2+
from typing import Any, Optional, Union, cast
3+
4+
import httpx
5+
6+
from ... import errors
7+
from ...client import AuthenticatedClient, Client
8+
from ...models.agent_request import AgentRequest
9+
from ...models.agent_response import AgentResponse
10+
from ...models.error_response import ErrorResponse
11+
from ...models.http_validation_error import HTTPValidationError
12+
from ...types import UNSET, Response, Unset
13+
14+
15+
def _get_kwargs(
16+
graph_id: str,
17+
*,
18+
body: AgentRequest,
19+
authorization: Union[None, Unset, str] = UNSET,
20+
auth_token: Union[None, Unset, str] = UNSET,
21+
) -> dict[str, Any]:
22+
headers: dict[str, Any] = {}
23+
if not isinstance(authorization, Unset):
24+
headers["authorization"] = authorization
25+
26+
cookies = {}
27+
if auth_token is not UNSET:
28+
cookies["auth-token"] = auth_token
29+
30+
_kwargs: dict[str, Any] = {
31+
"method": "post",
32+
"url": f"/v1/{graph_id}/agent",
33+
"cookies": cookies,
34+
}
35+
36+
_kwargs["json"] = body.to_dict()
37+
38+
headers["Content-Type"] = "application/json"
39+
40+
_kwargs["headers"] = headers
41+
return _kwargs
42+
43+
44+
def _parse_response(
45+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
46+
) -> Optional[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]:
47+
if response.status_code == 200:
48+
response_200 = AgentResponse.from_dict(response.json())
49+
50+
return response_200
51+
if response.status_code == 400:
52+
response_400 = cast(Any, None)
53+
return response_400
54+
if response.status_code == 402:
55+
response_402 = cast(Any, None)
56+
return response_402
57+
if response.status_code == 429:
58+
response_429 = cast(Any, None)
59+
return response_429
60+
if response.status_code == 500:
61+
response_500 = ErrorResponse.from_dict(response.json())
62+
63+
return response_500
64+
if response.status_code == 422:
65+
response_422 = HTTPValidationError.from_dict(response.json())
66+
67+
return response_422
68+
if client.raise_on_unexpected_status:
69+
raise errors.UnexpectedStatus(response.status_code, response.content)
70+
else:
71+
return None
72+
73+
74+
def _build_response(
75+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
76+
) -> Response[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]:
77+
return Response(
78+
status_code=HTTPStatus(response.status_code),
79+
content=response.content,
80+
headers=response.headers,
81+
parsed=_parse_response(client=client, response=response),
82+
)
83+
84+
85+
def sync_detailed(
86+
graph_id: str,
87+
*,
88+
client: AuthenticatedClient,
89+
body: AgentRequest,
90+
authorization: Union[None, Unset, str] = UNSET,
91+
auth_token: Union[None, Unset, str] = UNSET,
92+
) -> Response[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]:
93+
"""Auto-select agent for query
94+
95+
Automatically select the best agent for your query.
96+
97+
The orchestrator will:
98+
1. Enrich context with RAG if enabled
99+
2. Evaluate all available agents
100+
3. Select the best match based on confidence scores
101+
4. Execute the query with the selected agent
102+
103+
Use this endpoint when you want the system to intelligently route your query.
104+
105+
Args:
106+
graph_id (str):
107+
authorization (Union[None, Unset, str]):
108+
auth_token (Union[None, Unset, str]):
109+
body (AgentRequest): Request model for agent interactions.
110+
111+
Raises:
112+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
113+
httpx.TimeoutException: If the request takes longer than Client.timeout.
114+
115+
Returns:
116+
Response[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]
117+
"""
118+
119+
kwargs = _get_kwargs(
120+
graph_id=graph_id,
121+
body=body,
122+
authorization=authorization,
123+
auth_token=auth_token,
124+
)
125+
126+
response = client.get_httpx_client().request(
127+
**kwargs,
128+
)
129+
130+
return _build_response(client=client, response=response)
131+
132+
133+
def sync(
134+
graph_id: str,
135+
*,
136+
client: AuthenticatedClient,
137+
body: AgentRequest,
138+
authorization: Union[None, Unset, str] = UNSET,
139+
auth_token: Union[None, Unset, str] = UNSET,
140+
) -> Optional[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]:
141+
"""Auto-select agent for query
142+
143+
Automatically select the best agent for your query.
144+
145+
The orchestrator will:
146+
1. Enrich context with RAG if enabled
147+
2. Evaluate all available agents
148+
3. Select the best match based on confidence scores
149+
4. Execute the query with the selected agent
150+
151+
Use this endpoint when you want the system to intelligently route your query.
152+
153+
Args:
154+
graph_id (str):
155+
authorization (Union[None, Unset, str]):
156+
auth_token (Union[None, Unset, str]):
157+
body (AgentRequest): Request model for agent interactions.
158+
159+
Raises:
160+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
161+
httpx.TimeoutException: If the request takes longer than Client.timeout.
162+
163+
Returns:
164+
Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]
165+
"""
166+
167+
return sync_detailed(
168+
graph_id=graph_id,
169+
client=client,
170+
body=body,
171+
authorization=authorization,
172+
auth_token=auth_token,
173+
).parsed
174+
175+
176+
async def asyncio_detailed(
177+
graph_id: str,
178+
*,
179+
client: AuthenticatedClient,
180+
body: AgentRequest,
181+
authorization: Union[None, Unset, str] = UNSET,
182+
auth_token: Union[None, Unset, str] = UNSET,
183+
) -> Response[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]:
184+
"""Auto-select agent for query
185+
186+
Automatically select the best agent for your query.
187+
188+
The orchestrator will:
189+
1. Enrich context with RAG if enabled
190+
2. Evaluate all available agents
191+
3. Select the best match based on confidence scores
192+
4. Execute the query with the selected agent
193+
194+
Use this endpoint when you want the system to intelligently route your query.
195+
196+
Args:
197+
graph_id (str):
198+
authorization (Union[None, Unset, str]):
199+
auth_token (Union[None, Unset, str]):
200+
body (AgentRequest): Request model for agent interactions.
201+
202+
Raises:
203+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
204+
httpx.TimeoutException: If the request takes longer than Client.timeout.
205+
206+
Returns:
207+
Response[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]
208+
"""
209+
210+
kwargs = _get_kwargs(
211+
graph_id=graph_id,
212+
body=body,
213+
authorization=authorization,
214+
auth_token=auth_token,
215+
)
216+
217+
response = await client.get_async_httpx_client().request(**kwargs)
218+
219+
return _build_response(client=client, response=response)
220+
221+
222+
async def asyncio(
223+
graph_id: str,
224+
*,
225+
client: AuthenticatedClient,
226+
body: AgentRequest,
227+
authorization: Union[None, Unset, str] = UNSET,
228+
auth_token: Union[None, Unset, str] = UNSET,
229+
) -> Optional[Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]]:
230+
"""Auto-select agent for query
231+
232+
Automatically select the best agent for your query.
233+
234+
The orchestrator will:
235+
1. Enrich context with RAG if enabled
236+
2. Evaluate all available agents
237+
3. Select the best match based on confidence scores
238+
4. Execute the query with the selected agent
239+
240+
Use this endpoint when you want the system to intelligently route your query.
241+
242+
Args:
243+
graph_id (str):
244+
authorization (Union[None, Unset, str]):
245+
auth_token (Union[None, Unset, str]):
246+
body (AgentRequest): Request model for agent interactions.
247+
248+
Raises:
249+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
250+
httpx.TimeoutException: If the request takes longer than Client.timeout.
251+
252+
Returns:
253+
Union[AgentResponse, Any, ErrorResponse, HTTPValidationError]
254+
"""
255+
256+
return (
257+
await asyncio_detailed(
258+
graph_id=graph_id,
259+
client=client,
260+
body=body,
261+
authorization=authorization,
262+
auth_token=auth_token,
263+
)
264+
).parsed

0 commit comments

Comments
 (0)