Use A2A DeepAgents model resolver
This commit is contained in:
@@ -31,7 +31,7 @@ Keep this line when building DeepAgents graphs:
|
||||
|
||||
```python
|
||||
backend = ctx.workspace_backend()
|
||||
return create_deep_agent(model=model, backend=backend, tools=[...])
|
||||
return create_a2a_deep_agent(ctx, creds=creds, backend=backend, tools=[...])
|
||||
```
|
||||
|
||||
Invoke DeepAgents graphs with the starter recursion budget:
|
||||
@@ -75,7 +75,7 @@ after the request. Use the sandbox helpers for any file-producing toolchain.
|
||||
If this project grows reusable workflow knowledge, add source-controlled skill
|
||||
folders under `skills/<skill-name>/SKILL.md`. The starter's `_seed_runtime_skills`
|
||||
helper copies those packaged skills into the invocation workspace and passes the
|
||||
resulting source path to `create_deep_agent(..., skills=[...])`, which is how
|
||||
resulting source path to `create_a2a_deep_agent(..., skills=[...])`, which is how
|
||||
DeepAgents discovers skills with progressive disclosure.
|
||||
|
||||
## Run Locally
|
||||
|
||||
26
agent.py
26
agent.py
@@ -95,10 +95,9 @@ class ChartAgent(A2AAgent[ChartAgentConfig, NoAuth]):
|
||||
) -> Any:
|
||||
# Lazy imports keep `a2a card` usable before local dependencies are
|
||||
# installed. `a2a deploy` installs requirements.txt during the build.
|
||||
from deepagents import create_deep_agent
|
||||
from a2a_pack.deepagents import create_a2a_deep_agent
|
||||
from langchain.agents.middleware import wrap_model_call
|
||||
from langchain_core.tools import tool
|
||||
from langchain_openai import ChatOpenAI
|
||||
|
||||
@tool
|
||||
def text_stats(text: str) -> str:
|
||||
@@ -121,27 +120,12 @@ class ChartAgent(A2AAgent[ChartAgentConfig, NoAuth]):
|
||||
)
|
||||
return await handler(request)
|
||||
|
||||
model_kwargs: dict[str, Any] = {
|
||||
"model": creds.model,
|
||||
"base_url": creds.base_url,
|
||||
# For CALLER_PROVIDED this is the caller's forwarded key. For
|
||||
# PLATFORM this is the short-lived A2A LiteLLM grant token. Do not
|
||||
# substitute provider keys, LiteLLM master keys, or fake fallback
|
||||
# values here.
|
||||
"api_key": creds.api_key,
|
||||
}
|
||||
if creds.temperature_mode != "omit":
|
||||
model_kwargs["temperature"] = (
|
||||
creds.temperature if creds.temperature is not None else 0.0
|
||||
)
|
||||
if creds.extra_body:
|
||||
model_kwargs["extra_body"] = dict(creds.extra_body)
|
||||
|
||||
model = ChatOpenAI(**model_kwargs)
|
||||
backend = ctx.workspace_backend()
|
||||
skill_sources = _seed_runtime_skills(backend, ctx)
|
||||
return create_deep_agent(
|
||||
model=model,
|
||||
return create_a2a_deep_agent(
|
||||
ctx,
|
||||
creds=creds,
|
||||
default_temperature=0.0,
|
||||
backend=backend,
|
||||
skills=skill_sources or None,
|
||||
tools=[text_stats],
|
||||
|
||||
Reference in New Issue
Block a user