Use A2A DeepAgents model resolver

This commit is contained in:
2026-06-06 20:30:09 -03:00
parent 4f4da2a7f3
commit fdd620ef17
2 changed files with 7 additions and 23 deletions

View File

@@ -31,7 +31,7 @@ Keep this line when building DeepAgents graphs:
```python ```python
backend = ctx.workspace_backend() 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: 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 If this project grows reusable workflow knowledge, add source-controlled skill
folders under `skills/<skill-name>/SKILL.md`. The starter's `_seed_runtime_skills` 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 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. DeepAgents discovers skills with progressive disclosure.
## Run Locally ## Run Locally

View File

@@ -95,10 +95,9 @@ class ChartAgent(A2AAgent[ChartAgentConfig, NoAuth]):
) -> Any: ) -> Any:
# Lazy imports keep `a2a card` usable before local dependencies are # Lazy imports keep `a2a card` usable before local dependencies are
# installed. `a2a deploy` installs requirements.txt during the build. # 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.agents.middleware import wrap_model_call
from langchain_core.tools import tool from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
@tool @tool
def text_stats(text: str) -> str: def text_stats(text: str) -> str:
@@ -121,27 +120,12 @@ class ChartAgent(A2AAgent[ChartAgentConfig, NoAuth]):
) )
return await handler(request) 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() backend = ctx.workspace_backend()
skill_sources = _seed_runtime_skills(backend, ctx) skill_sources = _seed_runtime_skills(backend, ctx)
return create_deep_agent( return create_a2a_deep_agent(
model=model, ctx,
creds=creds,
default_temperature=0.0,
backend=backend, backend=backend,
skills=skill_sources or None, skills=skill_sources or None,
tools=[text_stats], tools=[text_stats],