diff --git a/agent_builder/builder.py b/agent_builder/builder.py index 2eee6d5..a646193 100644 --- a/agent_builder/builder.py +++ b/agent_builder/builder.py @@ -3,12 +3,12 @@ from __future__ import annotations from dataclasses import dataclass from pathlib import Path +from types import SimpleNamespace from typing import Any -from deepagents import create_deep_agent +from a2a_pack.deepagents import create_a2a_deep_agent from deepagents.backends import CompositeBackend, StateBackend, StoreBackend from deepagents.backends.utils import create_file_data -from langchain_openai import ChatOpenAI from langgraph.store.memory import InMemoryStore from .config import Settings, load_settings @@ -50,8 +50,8 @@ control plane. The default starter is the current a2a-pack DeepAgents scaffold. It declares ``LLMProvisioning.PLATFORM``, reads the caller's saved LLM credential from -``ctx.llm``, builds a ``ChatOpenAI`` model from those credentials, and wires a small -tool-calling DeepAgent with ``create_deep_agent`` plus ``wrap_model_call`` + ``ctx.llm``, resolves the model through ``create_a2a_deep_agent``, and wires a small + tool-calling DeepAgent with the A2A DeepAgents model middleware middleware. Do not recreate this from memory: call ``init_agent_template`` first and modify the generated files. @@ -60,8 +60,8 @@ Default hosted generated/user agents to ``LLMProvisioning.PLATFORM`` and credential for the callee. The generated agent must still read ``ctx.llm`` and must never read ``A2A_LITELLM_KEY``, ``OPENAI_API_KEY``, LiteLLM master keys, or provider keys directly. ``LLMProvisioning.CALLER_PROVIDED`` is still acceptable for -explicit BYOK wording. Always make missing ``ctx.llm.api_key`` a clear setup/config result before constructing -``ChatOpenAI``. + explicit BYOK wording. Always make missing ``ctx.llm.api_key`` a clear setup/config result before constructing + a DeepAgents model. ``Pricing`` accepts only ``price_per_call_usd``, ``caller_pays_llm``, and ``notes``. Never set ``runtime.pricing.compute`` or ``runtime.pricing.total_usd`` in generated source; those are derived later by @@ -325,21 +325,15 @@ def build_agent_builder(ctx: BuilderContext) -> Any: grant_token=ctx.grant_token, ) ) - model_kwargs: dict[str, Any] = { - "model": ctx.llm_model or settings.litellm_model, - "base_url": ctx.llm_base_url or (settings.litellm_url + "/v1"), - "api_key": ctx.llm_api_key or settings.litellm_key, - "stream_usage": True, - } - if ctx.llm_temperature_mode != "omit": - model_kwargs["temperature"] = ( - ctx.llm_temperature if ctx.llm_temperature is not None else 0.0 - ) - if ctx.llm_extra_body: - model_kwargs["extra_body"] = dict(ctx.llm_extra_body) - model = ChatOpenAI(**model_kwargs) + llm_creds = SimpleNamespace( + model=ctx.llm_model or settings.litellm_model, + base_url=ctx.llm_base_url or (settings.litellm_url + "/v1"), + api_key=ctx.llm_api_key or settings.litellm_key, + temperature_mode=ctx.llm_temperature_mode or "default", + temperature=ctx.llm_temperature, + extra_body=dict(ctx.llm_extra_body or {}), + ) kwargs: dict[str, Any] = { - "model": model, "tools": tools, "system_prompt": SYSTEM_PROMPT, } @@ -347,7 +341,12 @@ def build_agent_builder(ctx: BuilderContext) -> Any: if backend is not None: kwargs["backend"] = backend kwargs["skills"] = [BUILDER_SKILL_SOURCE] - return create_deep_agent(**kwargs) + return create_a2a_deep_agent( + ctx, + creds=llm_creds, + default_temperature=0.0, + **kwargs, + ) def _build_project_backend(ctx: BuilderContext, *, settings: Settings) -> Any | None: