Skip to content

Commit bfcb2c2

Browse files
phurynclaude
andcommitted
openai-agents: same universal model mapping; bump 0.4.1
Mirror the google-adk resolver on the OpenAI export: DEFAULT_OPENAI_MODEL (env AGENTLIFT_OPENAI_MODEL, default gpt-5-mini) + editable MODEL_MAP, each agent uses model=openai_model('<folder-id>'). Both exports are now runnable, transparent about the origin id, and resilient to model-name churn. Refreshed the __init__ docstring (export lists all three targets; deploy is Anthropic + Google live). 39 offline tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5b47933 commit bfcb2c2

4 files changed

Lines changed: 28 additions & 6 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "agentlift"
7-
version = "0.4.0"
7+
version = "0.4.1"
88
description = "Own your agent as a neutral folder; audit its portability, compile it to provider formats (Anthropic YAML / Google ADK), and deploy it to managed runtimes. Own the definition, rent the runtime."
99
readme = "README.md"
1010
requires-python = ">=3.10"

src/agentlift/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
provider-neutral definition. agentlift is a compiler over it:
55
66
audit how it maps across providers (native / emulated / degraded / unsupported)
7-
export compile it to a provider artifact (Anthropic YAML for `ant`, Google ADK)
8-
deploy push it to a managed runtime via API (Anthropic today)
7+
export compile it to a provider artifact (Anthropic YAML for `ant`, Google ADK,
8+
OpenAI Agents SDK)
9+
deploy push it to a managed runtime via API (Anthropic + Google, both live)
910
1011
Public surface:
1112
from agentlift import parse_project, build_plan, Deployer
1213
from agentlift import run_audit, export_anthropic_yaml, export_google_adk
1314
"""
1415

15-
__version__ = "0.4.0"
16+
__version__ = "0.4.1"
1617

1718
from .audit import run_audit # noqa: F401
1819
from .capabilities import CAPABILITIES, FEATURES # noqa: F401

src/agentlift/export.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ def export_openai_agents(project) -> dict:
187187
via ``as_tool()`` (confirmed working in experiments/subagent-composition). The
188188
orchestration loop runs in YOUR process -- the ``emulated`` subagents tier."""
189189
o = CAPABILITIES["openai"]
190+
claude_models = sorted({a.model for a in project.agents if a.model and a.model.startswith("claude")})
191+
map_lines = [f" {m!r}: DEFAULT_OPENAI_MODEL," for m in claude_models]
190192
out = [
191193
'"""Generated by `agentlift export openai-agents` - PREVIEW.',
192194
"",
@@ -196,10 +198,26 @@ def export_openai_agents(project) -> dict:
196198
"not OpenAI-hosted: that is the `emulated` subagents tier agentlift audit reports.",
197199
'"""',
198200
"import asyncio",
201+
"import os",
199202
"",
200203
"from agents import Agent, Runner",
201204
"",
202-
"# NOTE: models below are the folder's Claude ids; on OpenAI map them to a gpt-* id.",
205+
"# Model ids change often, so the folder -> OpenAI mapping lives in one place.",
206+
"# Override the default for every Claude-origin agent with AGENTLIFT_OPENAI_MODEL,",
207+
"# or edit MODEL_MAP for per-id control. Non-Claude ids pass through unchanged.",
208+
'DEFAULT_OPENAI_MODEL = os.environ.get("AGENTLIFT_OPENAI_MODEL", "gpt-5-mini")',
209+
"MODEL_MAP = {",
210+
*map_lines,
211+
"}",
212+
"",
213+
"",
214+
"def openai_model(folder_model):",
215+
" if folder_model in MODEL_MAP:",
216+
" return MODEL_MAP[folder_model]",
217+
" # an unmapped Claude id still needs an OpenAI model; anything else is",
218+
" # assumed to already be a valid OpenAI model id and passes through.",
219+
' return DEFAULT_OPENAI_MODEL if folder_model.startswith("claude") else folder_model',
220+
"",
203221
"",
204222
]
205223
roster = [a for a in project.agents if not a.subagents]
@@ -250,7 +268,7 @@ def _openai_agent_block(a, o, is_coordinator: bool) -> list:
250268
)
251269
lines.append(f"{_ident(a.name)} = Agent(")
252270
lines.append(f" name={a.name!r},")
253-
lines.append(f" model={a.model!r},")
271+
lines.append(f" model=openai_model({a.model!r}),")
254272
lines.append(f" instructions={_py(a.system)},")
255273
lines.append(" tools=[")
256274
lines += tool_lines

tests/test_export.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,6 @@ def test_openai_agents_is_valid_python_with_subagent_tools(examples_dir):
8787
assert "Runner.run(" in code # runnable entrypoint
8888
# the coordinator's roster shows up as ask_<name> tools
8989
assert "ask_bug_finder" in code and "ask_researcher" in code
90+
assert "def openai_model(" in code # universal model mapping, mirrors google-adk
91+
assert "AGENTLIFT_OPENAI_MODEL" in code
92+
assert "model=openai_model(" in code

0 commit comments

Comments
 (0)