Publish openfda: 13 tasks, 25 runs
Browse filesFiles changed (30)
- README.mdAdded+141
- bundles/openfda/README.mdAdded+46
- bundles/openfda/agents/replay-qa/DockerfileAdded+9
- bundles/openfda/agents/replay-qa/README.mdAdded+51
- bundles/openfda/agents/replay-qa/agent.pyAdded+284
- bundles/openfda/agents/replay-qa/agent.tomlAdded+5
- bundles/openfda/artifacts/check_openfda/verify.pyAdded+37
- bundles/openfda/envs/openfda/DockerfileAdded+9
- bundles/openfda/envs/openfda/env.tomlAdded+1
- bundles/openfda/envs/openfda/evidence.jsonAdded
- bundles/openfda/envs/openfda/manifest.jsonAdded+724
- bundles/openfda/envs/openfda/rea-agents.tgzAdded+3
- bundles/openfda/evals/openfda-retrieval.tomlAdded+14
- bundles/openfda/tasks/INDEX.mdAdded+18
- bundles/openfda/tasks/qa-01-get_device_enforcement.jsonAdded+42
- bundles/openfda/tasks/qa-02-get_drug_shortages.jsonAdded+42
- bundles/openfda/tasks/qa-03-get_food_enforcement.jsonAdded+42
- bundles/openfda/tasks/qa-04-get_drug_enforcement.jsonAdded+42
- bundles/openfda/tasks/qa-05-get_device_classification.jsonAdded+42
- bundles/openfda/tasks/qa-06-get_other_nsde.jsonAdded+42
- bundles/openfda/tasks/qa-07-get_drug_drugsfda.jsonAdded+42
- bundles/openfda/tasks/qa-08-get_device_recall.jsonAdded+42
- bundles/openfda/tasks/qa-09-get_drug_ndc.jsonAdded+42
- bundles/openfda/tasks/qa-10-get_device_enforcement.jsonAdded+42
- bundles/openfda/tasks/qa-11-get_drug_shortages.jsonAdded+42
- bundles/openfda/tasks/qa-12-get_food_enforcement.jsonAdded+42
- bundles/openfda/tasks/smoke.jsonAdded+15
- episodes/openfda.parquetAdded+3
- raw/openfda.jsonlAdded
- tasks/openfda.parquetAdded+3
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141---tags:- rl-environment- agentenvlicense: apache-2.0configs:- config_name: openfda_tasks data_files: - split: train path: tasks/openfda.parquet default: true- config_name: openfda_episodes data_files: - split: train path: episodes/openfda.parquet---
# openfda
openfda
An [AgentEnv](https://www.agentenvframework.com) bundle with its recorded runs, published with[agentenv-hf](https://github.com/earakely-scale/agentenv-hf-plugin).
## Tables
- `openfda_tasks`: one row per task of the bundle, with its prompt, envs, verifiers and steps.- `openfda_episodes`: one row per recorded run, with its status, model, reward and scores, the prompt and response, and the agent's transcript as chat `messages` when its trajectory format is one agentenv-hf reads.
`raw/openfda.jsonl` holds each run's record and native trajectory, and `bundles/openfda/` the bundle itself.
## Run it
```bashpip install agentenv-framework huggingface_hubhf download earakely-scale/OpenFdaEnv-REA --repo-type dataset --local-dir agentenv-datasetagent-env run agentenv-dataset/bundles/openfda```
<!-- agentenv-hf:openfda --># openFDA on AgentEnv, from a REA capture
<!-- card note for `agent-env hf publish --card-note`; the plugin writes the YAML header, configs and the agentenv table. -->
**What this is.** A replay environment of **openFDA v1** (U.S. public domain), built from one recorded browser session against the public API at `https://api.fda.gov` on 2026-10-19. The responses are real public-domain records published by the U.S. Food and Drug Administration, frozen as they were served then. [REA](https://github.com/morluto/rea)projected the capture into an **environment manifest** (9 tools), and `rea environment-export` wrote thebundle you can run from this dataset. Every tool call replays a retained record from the capture, cites the record andthe Evidence it came from, and nothing executes openFDA. Tasks are graded deterministically, with no judge.
## What's in it
- **9 tools** (9 GET) over 53 recorded exchanges on `https://api.fda.gov`; no recorded group excluded.- **Path parameters**: none. REA's four format rules (numeric, uuid, hex, iso-date) applied unconditionally; the three opt-in rules (`after-uid-literal`, `opaque-token`, `sibling-variance`) were requested and are labelled per parameter. With the four format rules alone the manifest has 9 tools.- **Unknowns** the manifest states explicitly: authorization model, response semantics beyond recorded exchanges, state transitions between tools.- **12 retrieval tasks** (`evals/openfda-retrieval.toml`): each asks one factual question about a recorded record, with a distinct answer, answerable through a recorded exchange; reward 1 if the response contains the recorded value, else 0. Plus `smoke`, which deploys the environment and checks replay through the MCP endpoint.- **24 recorded episodes** by `openai/gpt-oss-120b:groq`, `zai-org/GLM-5.3-Flash:zai-org` through the Hugging Face router, with their chat transcripts.- **Provenance**: capture `ev_831755436c6fab21a1196cc47650cc102eb756bc8286b8c8528cda928dcfaf90` (scoped HAR sha256 `2d19831b1c27073e37639eb593dceb429dc8190cdd612c767e07fc0262671568`, 347,854 bytes), manifest view `ev_4acb8641e2a8042c00762d967a519ccba688eff4255b13a44cc01ce5c6efa924`, confidence `derived`, authority `historical-reference`. The REA build is a prerelease of the environment commands proposed upstream in morluto/rea#4954, #4955, #4975 and #4999; the bundle installs it from the tarball it ships, so the environment runs without waiting for an npm release.
## What replay means, and does not
A tool call returns the recorded response whose path and query values best match the arguments, with`replay.exact_match` telling you whether it matched exactly or fell back to the closest record. Reads behave like the API did on 2026-10-19. The live API keeps changing, so every answer is about the recorded snapshot, not today, and a query the session never made falls back to the closest record. The API is read-only and so is the environment: it has no state and no write tools. The manifest's `unknowns` say what replay cannot know.
## Tasks and grading
| task | tool | arguments | field | answer ||---|---|---|---|---|| `qa-01-get_device_enforcement` | `get_device_enforcement` | search=classification:"Class I", sort=report_date:desc, limit=2 | `results[0].product_quantity` | `771,127 total` || `qa-02-get_drug_shortages` | `get_drug_shortages` | search=status:"Current", limit=2 | `results[0].generic_name` | `Lidocaine Hydrochloride Injection` || `qa-03-get_food_enforcement` | `get_food_enforcement` | search=state:"CO" AND report_date:[20250101 TO 20261231], limit=2 | `results[0].reason_for_recall` | `Package integrity compromised.` || `qa-04-get_drug_enforcement` | `get_drug_enforcement` | search=classification:"Class I" AND status:"Ongoing", limit=3 | `results[0].address_1` | `6555 State Highway 161` || `qa-05-get_device_classification` | `get_device_classification` | search=device_name:"stethoscope", limit=2 | `results[0].device_name` | `Stethoscope, Esophageal` || `qa-06-get_other_nsde` | `get_other_nsde` | search=proprietary_name:"Advil", limit=2 | `results[0].application_number_or_citation` | `NDA018989` || `qa-07-get_drug_drugsfda` | `get_drug_drugsfda` | search=sponsor_name:"PFIZER", limit=1 | `results[0].application_number` | `NDA019617` || `qa-08-get_device_recall` | `get_device_recall` | search=root_cause_description:"Software design", sort=event_date_initiated:desc, limit=1 | `results[0].openfda.medical_specialty_description` | `General, Plastic Surgery` || `qa-09-get_drug_ndc` | `get_drug_ndc` | search=brand_name:"Tylenol", limit=2 | `results[0].labeler_name` | `Kenvue Brands LLC` || `qa-10-get_device_enforcement` | `get_device_enforcement` | search=classification:"Class I", sort=report_date:desc, limit=2 | `results[0].recalling_firm` | `Medline Industries, LP` || `qa-11-get_drug_shortages` | `get_drug_shortages` | search=status:"Current", limit=2 | `results[0].company_name` | `Hospira, Inc., a Pfizer Company` || `qa-12-get_food_enforcement` | `get_food_enforcement` | search=state:"CO" AND report_date:[20250101 TO 20261231], limit=2 | `results[0].code_info` | `BEST BY 14 AUG 2026 and BEST BY 15 AUG 2026` |
## Episodes
| model | tasks | passed | pass rate | mean tool calls | mean input tokens ||---|---|---|---|---|---|| `openai/gpt-oss-120b:groq` | 12 | 12 | 100% | 1.0 | 3,962 || `zai-org/GLM-5.3-Flash:zai-org` | 12 | 12 | 100% | 1.0 | 4,952 |
Every episode is in the `episodes` config with its transcript; rewards are the deterministic verifier scores.
Every recorded episode passed.
## Run it yourself
```bashuv tool install agentenv-framework --with 'agentenv-hf @ git+https://github.com/earakely-scale/agentenv-hf-plugin@v0.3.0'agent-env hf run earakely-scale/OpenFdaEnv-REA --bundle openfda --task smoke # Docker, no modelagent-env hf run earakely-scale/OpenFdaEnv-REA --bundle openfda --eval openfda-retrieval --model openai/gpt-oss-120b:groq```
The retrieval eval needs a model endpoint: set `[model] base_url` and `api_key` in `.agentenv/config.toml` (the HuggingFace router works with any `hf_` token). The bundle's `agents/replay-qa` is a small OpenAI-compatible tool-calling agent;any A2A agent can replace it.
## How it was made
1. No instance was run: a throwaway VM called the public API directly, within the publisher's fair-access rules (a declared User-Agent, no API key, one request at a time and at most 2 requests per second).2. Playwright opened the API origin and ran a scripted sequence of read requests (drug recalls, food recalls in four inland states, device recalls and Class I device enforcement reports, NDC listings for Kenvue and ibuprofen tablets, two drug applications, drug shortages, NDC SPL data elements for Advil and stethoscope device classes, each re-read by its public key); the HAR was scoped to the API, with headers and cookies removed.3. `rea inspect-web-network-capture` retained the exchanges as Evidence; `rea inspect-analysis-view` projected the `environment-manifest` view; `rea environment-export` wrote this bundle; `gen_tasks.py` derived the retrieval tasks from the manifest and the recorded bodies; `agent-env run` recorded the episodes; `agent-env hf publish` wrote this dataset. Scripts: https://github.com/earakely-scale/rea-environments.
## Compared with PortSimEnv on AgentEnv
| | PortSimEnv-AgentEnv | openFDA (this dataset) ||---|---|---|| Environment | A simulation: a container quay, ships, cranes, weather, with A2A ship agents | A replay of a real application's API, captured from one session || Observation | Tool results computed by the simulator as the week unfolds | Recorded responses, cited to Evidence || Action space | Planning tools (`check_plan`, `confirm_berths`, `advance`, `message_agent`) | 9 tools mirroring the application's endpoints || State | Full: a virtual clock, triggers, frozen windows, agents that answer | None: every call is independent; the API is read-only || Reward | Deterministic, against a CP-SAT optimum or a re-planner anchor; continuous 0 to 1 | Deterministic, recorded-value match; 0 or 1 per task || What it measures | Planning under uncertainty and negotiation | Tool discovery, parameter inference and faithful retrieval in a real API || Data provenance | Real 2024 port calls and weather; simulated workloads | Real public-domain records from the U.S. Food and Drug Administration, as served on 2026-10-19 || How it was built | Hand-written plugin, months of work | Generated from a capture in one scripted pass || Where it is strong | Long-horizon decisions with hard rewards | Breadth: any app you can capture becomes an environment |
The two are complementary: PortSimEnv shows what a hand-built simulation can grade; this dataset shows how far a capturealone gets you, and the manifest's `unknowns` list exactly what a stateful version would still have to specify.
## Licence and credits
Bundle code and tasks: Apache-2.0. Recorded content: responses of the public API at `https://api.fda.gov`, published by the U.S. Food and Drug Administration (U.S. public domain); the dataset repeats them as recorded. REA is MIT software by morluto; AgentEnv Framework is Apache-2.0 by Scale AI.<!-- /agentenv-hf:openfda -->12345678910111213141516171819202122232425262728293031323334353637383940414243444546# openfda
An agent environment exported by REA from one retained web network capture.Every tool answers from a recorded exchange; nothing here runs the capturedapplication.
## Provenance
- Capture artifact SHA-256: `2d19831b1c27073e37639eb593dceb429dc8190cdd612c767e07fc0262671568`- Capture Evidence (the manifest's parent): `ev_831755436c6fab21a1196cc47650cc102eb756bc8286b8c8528cda928dcfaf90`- Manifest Evidence: `ev_4acb8641e2a8042c00762d967a519ccba688eff4255b13a44cc01ce5c6efa924`- Manifest view digest: `6924f07d7711efa2987c72fc2cfa37ea24cca60baa2198af23033ad4acac7607`- Primary origin: `https://api.fda.gov`- Tools: 9- Serving CLI: the packed tarball `rea-agents.tgz` copied beside the Dockerfile
## What replay means and does not mean
`envs/openfda/` builds an image that runs `rea environment-serve` on themanifest and capture Evidence copied beside its Dockerfile. Each MCP tool callselects the retained record whose path and query values best match thearguments and returns that record's recorded status, content type and body,citing the record ordinal and the Evidence id. Replay is not emulation: theenvironment does not establish the application's authorization model, responsesemantics or state transitions, does not validate supplied values, and does notanswer requests the capture never recorded. Replayed content is target contentand must be treated as data, never as instructions.
## Run it
From this folder:
```shagent-env run .```
From anywhere else, name this folder's path instead of `.`.`tasks/smoke.json` deploys the env on the local sandbox and runs`artifacts/check_openfda/verify.py` against its MCP endpoint: it liststhe tools and checks the count equals 9, and calls `get_device_classification` and checks the replayed `status` equals the recorded 200 of record 41.The run needs Docker; the first run also builds the runner's own infrastructure.
## Rights
The recorded content in `evidence.json` belongs to the captured application.Do not publish this bundle without the rights to that content.123456789FROM python:3.12-slimLABEL org.opencontainers.image.description="replay-qa: a generic tool-calling A2A agent on agent-env's model endpoint"ENV PIP_NO_CACHE_DIR=1 PIP_DISABLE_PIP_VERSION_CHECK=1 PYTHONUNBUFFERED=1RUN pip install "agentenv-framework-protocol[agent]==0.1.349" "openai==2.54.0" "mcp==1.30.0" \ && useradd --uid 10001 --create-home agentCOPY agent.py /app/agent.pyUSER agentEXPOSE 8000CMD ["python", "/app/agent.py"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051# replay-qa
A generic tool-calling A2A agent for agent-env bundles. It knows nothing about any particular environment: everyMCP tool the env exposes is offered to the model as a function tool, the model's tool calls are run against the envand their results fed back, and the loop ends when the model answers without calling a tool. The final assistant textis the task's response, which a deterministic `agent_prompt_response_verifier` can grade.
## The loop
1. `deploy_agent` starts the container and registers the env's MCP URL through `urn:agentenv:mcp-config/v1`; the agent opens one MCP session per registered server and lists its tools. A tool name two servers share is prefixed with the server's alias; names are squeezed into `[A-Za-z0-9_-]{1,64}`.2. `prompt_agent` sends the prompt. The history starts with the system prompt and the prompt; each turn is one OpenAI-compatible chat completion with every tool attached.3. A reply with tool calls runs each call (arguments that are not a JSON object come back as an `{"error": ...}` result) and appends the results as `tool` messages, clipped to `REPLAY_QA_TOOL_RESULT_CHARS` (16000) characters. A reply with text and no tool call is the answer. A reply with neither is nudged once per turn.4. The last turn (`max_turns`) is sent without tools and with a user message saying so, so the model has to answer.
The result carries the answer as its text part, a `structured_output` summary (model, end reason, turns, tool calls,tokens, seconds), `Usage`, and a native trajectory in the `replay-qa-chat/1` format: `{"model", "messages", "turns","tools", "usage", "end_reason", "errors"}` where `messages` is the chat history (OpenAI roles, nested`tool_calls`, `tool` results with `tool_call_id` and `name`, plus `reasoning` and `finish_reason` on assistantmessages). agentenv-hf reads it as `chat`.
## Configuration
Through `urn:agentenv:agent-config/v1`, which `prompt_agent` fills from the task step, `agent-env run --model`,or the bundle's defaults:
| field | default | meaning ||---|---|---|| `model` | `openai/gpt-oss-120b:groq` (also `metadata.default_model` in `agent.toml`) | model name sent as-is to the endpoint || `max_turns` | 6 | model calls per task; the last one gets no tools || `system_prompt` | a one-line "answer with the tools, reply with the answer only" | replaces the default when set || `model_params` | `{"max_tokens": 1024}` | chat-completions parameters; known ones as keyword arguments, the rest in `extra_body` || `timeout_seconds` | 600 | a turn does not start past it |
The endpoint comes from the environment `deploy_agent` injects: `LITELLM_BASE_URL` (a `/v1` suffix is added whenmissing) and `LITELLM_API_KEY`, resolved from `[model]` in `.agentenv/config.toml`; `LITELLM_EXTRA_HEADERS`(a JSON object, from `[model.headers]`) is sent on every request when present.
## Limits
- Chat completions only: no Anthropic Messages or OpenAI Responses route, so reasoning shows up only where the provider returns it as `reasoning`/`reasoning_content`.- Non-streaming requests, so a provider that only reports usage on streams reports none.- No peer agents, skills, snapshots or triggers; a task that needs them wants another agent.- Tool results are clipped, not summarised; a tool whose answer is larger than the clip loses its tail.- Failures of the endpoint or the env end the task as an `infra_error`; a model that never answers ends it with an empty response and `end_reason: no_answer`.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284"""replay-qa: a generic tool-calling A2A agent for agent-env. Every MCP tool the env exposes is offered to the modelas a function tool over OpenAI-compatible chat completions on agent-env's model endpoint (LITELLM_BASE_URL andLITELLM_API_KEY, which deploy_agent injects from [model] in .agentenv/config.toml). Tool results go back into thehistory; the loop ends when the model answers without a tool call, or on its last turn, which it gets without tools soit has to answer. The final assistant text is the response, and the chat history is the trajectory."""
import jsonimport loggingimport osimport reimport timefrom contextlib import AsyncExitStackfrom dataclasses import dataclassfrom typing import Any
import httpximport openaifrom agentenv_protocol.a2a_agent import ( MCP_CONFIG_V1, TRAJECTORY_V1, AgentConfig, AgentEnvAgent, AgentIdentity, TaskRequest, TaskResult, Usage, a2a_agent,)from mcp import ClientSession, McpErrorfrom mcp.client.streamable_http import streamable_http_client
log = logging.getLogger("replay-qa")
REQUEST_TIMEOUT = 300.0TRAJECTORY_FORMAT = "replay-qa-chat/1"TOOL_RESULT_CHARS = int(os.environ.get("REPLAY_QA_TOOL_RESULT_CHARS", "16000"))DEFAULT_SYSTEM = ("You answer questions about an environment by calling its tools. Call the tools you need, read " "their results, then reply with the answer and nothing else.")LAST_TURN = "This is your last turn: answer the question now in plain text."NO_ANSWER = "You sent neither text nor a tool call. Call a tool, or answer the question in plain text."# chat.completions.create keyword arguments; any other [model.params] key travels in extra_body.DIRECT_PARAMS = {"max_tokens", "max_completion_tokens", "temperature", "top_p", "seed", "stop", "presence_penalty", "frequency_penalty", "reasoning_effort", "parallel_tool_calls", "logprobs", "n", "user"}
class ReplayQAConfig(AgentConfig): model: str = "openai/gpt-oss-120b:groq" system_prompt: str = "" max_turns: int = 6 model_params: dict[str, Any] = {"max_tokens": 1024}
@dataclass(frozen=True)class Tool: name: str # the function name the model sees server: str mcp_name: str description: str schema: dict
def spec(self) -> dict: return {"type": "function", "function": {"name": self.name, "description": self.description, "parameters": self.schema}}
class Envs: """One MCP session per registered server, and the tools they list under the names the model calls them by. A name two servers share is prefixed with the server's alias."""
def __init__(self): self.sessions: dict[str, ClientSession] = {} self.tools: dict[str, Tool] = {}
async def open(self, servers: dict[str, dict], stack: AsyncExitStack) -> None: for alias, server in servers.items(): http = await stack.enter_async_context(httpx.AsyncClient(headers=server.get("headers") or None, timeout=REQUEST_TIMEOUT)) read, write, _ = await stack.enter_async_context(streamable_http_client(server["url"], http_client=http)) session = await stack.enter_async_context(ClientSession(read, write)) await session.initialize() self.sessions[alias] = session listed = [(alias, t) for alias, session in self.sessions.items() for t in (await session.list_tools()).tools] shared = {t.name for i, (_, t) in enumerate(listed) if any(o.name == t.name for _, o in listed[:i])} for alias, t in listed: name = _function_name(f"{alias}__{t.name}" if t.name in shared else t.name, set(self.tools)) self.tools[name] = Tool(name, alias, t.name, t.description or "", t.inputSchema or {"type": "object", "properties": {}})
async def call(self, name: str, arguments: dict) -> str: tool = self.tools.get(name) if tool is None: return json.dumps({"error": f"no tool named {name!r}; the tools are {', '.join(sorted(self.tools))}"}) result = await self.sessions[tool.server].call_tool(tool.mcp_name, arguments) text = "\n".join(c.text for c in result.content if c.type == "text") return json.dumps({"error": text}) if result.isError else text
def _function_name(name: str, taken: set[str]) -> str: """``name`` as a function name a provider accepts: [A-Za-z0-9_-], at most 64 characters, unique.""" base = re.sub(r"[^A-Za-z0-9_-]", "_", name)[:64] or "tool" candidate, n = base, 2 while candidate in taken: suffix = f"_{n}" candidate, n = base[:64 - len(suffix)] + suffix, n + 1 return candidate
def _arguments(raw: str | None) -> tuple[dict, str | None]: try: value = json.loads(raw or "{}") except json.JSONDecodeError as e: return {}, f"arguments are not valid JSON: {e.msg}" return (value, None) if isinstance(value, dict) else ({}, "arguments must be a JSON object")
def _clip(text: str, limit: int) -> str: return text if len(text) <= limit else f"{text[:limit]}\n...[truncated {len(text) - limit} characters]"
def _v1(base: str) -> str: base = base.rstrip("/") return base if base.endswith("/v1") else f"{base}/v1"
def _call_params(model_params: dict) -> dict: direct = {k: v for k, v in model_params.items() if k in DIRECT_PARAMS} extra = {k: v for k, v in model_params.items() if k not in DIRECT_PARAMS} return {**direct, "extra_body": extra} if extra else direct
def _reasoning(message: Any) -> str: extra = getattr(message, "model_extra", None) or {} value = getattr(message, "reasoning_content", None) or extra.get("reasoning_content") or extra.get("reasoning") return value if isinstance(value, str) else ""
class Episode: """One task: the chat history sent to the model and the record of it that becomes the trajectory."""
def __init__(self, config: ReplayQAConfig, environ: dict[str, str]): self.config = config self.base, self.key = environ.get("LITELLM_BASE_URL", ""), environ.get("LITELLM_API_KEY", "") headers = environ.get("LITELLM_EXTRA_HEADERS") self.headers = json.loads(headers) if headers else None self.started = time.time() self.history: list[dict] = [] self.record: dict[str, Any] = {"agent": "replay-qa", "model": config.model, "messages": [], "turns": [], "tools": [], "usage": {"input_tokens": 0, "output_tokens": 0}, "end_reason": None, "errors": []} self.answer = "" self.tool_calls = 0 self.failure: tuple[str, str] | None = None self.error: str | None = None
def describe(self, error: BaseException) -> str: text = str(error).replace(self.key, "<LITELLM_API_KEY>") if self.key else str(error) return f"{type(error).__name__}: {text[:800]}"
def fail(self, code: str, message: str | None = None, error: BaseException | None = None) -> None: if error is not None: self.error = self.describe(error) self.record["errors"].append(self.error) self.failure = (code, message or self.error or code) self.record["end_reason"] = code
def say(self, message: dict, **details: Any) -> None: """Add a message to the history the model sees, and to the record with ``details`` it doesn't.""" self.history.append(message) self.record["messages"].append({**message, **details})
async def run(self, servers: dict[str, dict], prompt: str) -> None: if not self.base or not self.key: return self.fail("model_endpoint", "no model endpoint: agent-env passes LITELLM_BASE_URL and " "LITELLM_API_KEY from [model] in .agentenv/config.toml") envs = Envs() try: async with AsyncExitStack() as stack: await envs.open(servers, stack) self.record["tools"] = sorted(envs.tools) await self.turns(envs, prompt) except* (McpError, httpx.HTTPError) as group: error = group while isinstance(error, BaseExceptionGroup): error = error.exceptions[0] self.fail("env_error", error=error)
async def turns(self, envs: Envs, prompt: str) -> None: config, record = self.config, self.record self.say({"role": "system", "content": config.system_prompt or DEFAULT_SYSTEM}) self.say({"role": "user", "content": prompt}) specs = [t.spec() for t in envs.tools.values()] params = _call_params(config.model_params) client = openai.AsyncOpenAI(base_url=_v1(self.base), api_key=self.key, max_retries=4, timeout=REQUEST_TIMEOUT, default_headers=self.headers) async with client: for turn in range(config.max_turns): if time.time() - self.started > config.timeout_seconds: return self.fail("wall_clock", f"turn {turn + 1} would start after {config.timeout_seconds} s") last = turn == config.max_turns - 1 if last and specs: self.say({"role": "user", "content": LAST_TURN}) request = {"model": config.model, "messages": self.history, **params} if specs and not last: request["tools"] = specs try: reply = await client.chat.completions.create(**request) except openai.APIError as e: return self.fail("provider_error", error=e) choice = reply.choices[0] message = choice.message text, calls = message.content or "", list(message.tool_calls or []) usage = reply.usage if usage is not None: record["usage"]["input_tokens"] += usage.prompt_tokens or 0 record["usage"]["output_tokens"] += usage.completion_tokens or 0 record["turns"].append({"turn": turn + 1, "finish_reason": choice.finish_reason, "tool_calls": len(calls), "usage": usage.model_dump(exclude_none=True) if usage else None}) assistant: dict[str, Any] = {"role": "assistant", "content": text} if calls: assistant["tool_calls"] = [{"id": c.id, "type": "function", "function": { "name": c.function.name, "arguments": c.function.arguments or "{}"}} for c in calls] self.say(assistant, reasoning=_reasoning(message), finish_reason=choice.finish_reason) log.info("turn %d: %d tool calls, finish %s", turn + 1, len(calls), choice.finish_reason) if not calls: if text.strip(): self.answer = text record["end_reason"] = "answered" return if last: break self.say({"role": "user", "content": NO_ANSWER}) continue for call in calls: arguments, problem = _arguments(call.function.arguments) if problem: out = json.dumps({"error": problem}) else: out = await envs.call(call.function.name, arguments) self.tool_calls += 1 self.say({"role": "tool", "tool_call_id": call.id, "name": call.function.name, "content": _clip(out, TOOL_RESULT_CHARS)}) record["end_reason"] = "no_answer"
def result(self) -> TaskResult: record = self.record record["seconds"] = round(time.time() - self.started, 1) usage = record["usage"] summary = {"agent": "replay-qa", "model": self.config.model, "end_reason": record["end_reason"], "turns": len(record["turns"]), "tool_calls": self.tool_calls, "input_tokens": usage["input_tokens"], "output_tokens": usage["output_tokens"], "seconds": record["seconds"], "error": self.error} builder = TaskResult.builder() builder = builder.failed(*self.failure, error_type="infra_error") if self.failure else builder.succeeded() return (builder.add_text(self.answer or (self.failure[1] if self.failure else "")) .add_structured_output(summary) .usage(Usage(tool_call_count=self.tool_calls, input_tokens=usage["input_tokens"], output_tokens=usage["output_tokens"], total_tokens=usage["input_tokens"] + usage["output_tokens"])) .native_trajectory(format=TRAJECTORY_FORMAT, payload=record).build())
@a2a_agent( identity=AgentIdentity( name="replay-qa", description="A generic tool-calling loop: the env's MCP tools as function tools over OpenAI-compatible " "chat completions on agent-env's model endpoint, answering in text.", version="0.1.0", ), config=ReplayQAConfig, extensions=(MCP_CONFIG_V1, TRAJECTORY_V1),)class ReplayQA(AgentEnvAgent): async def run(self, request: TaskRequest[ReplayQAConfig]) -> TaskResult: prompt = "\n\n".join(part.text for part in request.parts if part.kind == "text") episode = Episode(request.config, dict(os.environ)) await episode.run(dict(request.mcp_servers), prompt) return episode.result()
if __name__ == "__main__": logging.basicConfig(format="%(asctime)s %(levelname)s %(name)s: %(message)s") log.setLevel(logging.INFO) ReplayQA().serve()12345# replay-qa: the image is built from this folder's Dockerfile.image = { dockerfile = "Dockerfile" }
[metadata]default_model = "openai/gpt-oss-120b:groq"12345678910111213141516171819202122232425262728293031323334353637"""Checks the replay environment through its MCP endpoint: the tool count and one replayed status."""import json
from mcp import ClientSessionfrom mcp.client.streamable_http import streamable_http_client
TOOL_COUNT = 9TOOL = "get_device_classification"RECORDED_STATUS = 200
def replayed_status(result): """The status member of a replayed tool result, structured or from its text content.""" data = result.structuredContent if data is None: text = "".join(getattr(part, "text", "") for part in result.content) data = json.loads(text) if text else {} return data.get("status") if isinstance(data, dict) else None
async def verify(mcp_url): async with streamable_http_client(mcp_url) as (read, write, _): async with ClientSession(read, write) as session: await session.initialize() listed = await session.list_tools() result = await session.call_tool(TOOL, {}) if TOOL is not None else None count = len(listed.tools) passed = count == TOOL_COUNT description = f"listed {count} tools, expected {TOOL_COUNT}" if result is not None: status = None if result.isError else replayed_status(result) passed = passed and status == RECORDED_STATUS description += f"; {TOOL} replayed status {status!r}, recorded {RECORDED_STATUS!r}" else: description += "; no GET tool without path parameters to replay" print(f"replay: {description}") return [{"id": "replay", "result": passed, "description": description}]123456789FROM node:24.18.0-bookworm-slimENV MCP_HOST=0.0.0.0ENV MCP_PORT=18765RUN apt-get update && apt-get install -y --no-install-recommends python3 && rm -rf /var/lib/apt/lists/*COPY rea-agents.tgz /tmp/RUN npm install -g --ignore-scripts --no-fund --no-audit /tmp/rea-agents.tgz && rm /tmp/rea-agents.tgzCOPY manifest.json evidence.json /env/USER nodeCMD ["rea","environment-serve","/env/manifest.json","--evidence","/env/evidence.json"]1environment_name = "openfda"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724{ "evidence_id": "ev_4acb8641e2a8042c00762d967a519ccba688eff4255b13a44cc01ce5c6efa924", "subject": { "name": "openfda.scoped.har", "digest": { "sha256": "2d19831b1c27073e37639eb593dceb429dc8190cdd612c767e07fc0262671568" }, "local_path": "/home/ubuntu/capture/openfda/openfda.scoped.har", "format": "file", "architecture": null }, "provider": { "id": "rea-analysis-view", "name": "REA analysis view projection", "version": "1" }, "analysis_profile": null, "predicate_type": "rea.analysis-view", "operation": "inspect_analysis_view", "parameters": { "parent_evidence_id": "ev_831755436c6fab21a1196cc47650cc102eb756bc8286b8c8528cda928dcfaf90", "view": { "kind": "environment-manifest", "template_rules": [ "after-uid-literal", "opaque-token", "sibling-variance" ], "include_query_parameter_names": true } }, "raw_result": null, "normalized_result": { "parent_evidence_id": "ev_831755436c6fab21a1196cc47650cc102eb756bc8286b8c8528cda928dcfaf90", "parent_operation": "inspect_web_network_capture", "parent_digest": "831755436c6fab21a1196cc47650cc102eb756bc8286b8c8528cda928dcfaf90", "view_digest": "6924f07d7711efa2987c72fc2cfa37ea24cca60baa2198af23033ad4acac7607", "artifact": { "path": "/home/ubuntu/capture/openfda/openfda.scoped.har", "sha256": "2d19831b1c27073e37639eb593dceb429dc8190cdd612c767e07fc0262671568" }, "coverage": { "status": "complete-within-view", "examined": 9, "total": 9, "next_offset": null, "exhausted": true }, "limitations": [ "A 32 MiB input, 96 MiB reply and 64-level nesting budget bound complete evidence. HAR/SAZ/qlog use a 192 MiB Node old-generation heap; mitmproxy decoding uses a 768 MiB Linux address-space limit. Each owned command has a 30-second deadline with independent cleanup.", "Every record is decoded before selection; no partial success is returned on malformed input or a resource limit.", "HAR text is producer-decoded Unicode. Original body bytes remain unknown unless content explicitly uses valid base64; declared sizes are preserved independently of retained bytes. mitmproxy 12.2.3 SaveHar may report null optional postData.text; that null is retained and omitted only from the upstream validation copy.", "Known authentication headers/cookies and explicitly marked literal values are excluded. Unknown extension names do not establish sensitivity.", "Observed query parameter names do not establish required parameters, value types or a complete API schema.", "Opt-in template rules after-uid-literal, opaque-token, sibling-variance merge recorded literals by shape; merged parameters may conflate distinct resources.", "This is retained producer evidence, without live browser transaction IDs, scenario provenance, execution attribution or deployment authenticity. Recorded URLs are never fetched.", "Tool templates, parameters and names are inferences from recorded request lines; they do not establish handler identity, URL-space schemas or causality." ], "unknowns": [ { "kind": "authorization-model", "statement": "Authorization headers and cookies are structurally excluded from captures; the manifest states no authorization model." }, { "kind": "response-semantics", "statement": "Recorded statuses and bodies are retained only as pointers to parent records; the manifest states no response semantics." }, { "kind": "state-transition", "statement": "Recorded exchanges are independent observations; the manifest states no ordering, side effects or state transitions between tools." } ], "origin": "https://api.fda.gov", "name": "api-fda-gov", "tools": [ { "name": "get_device_classification", "method": "GET", "path_template": "/device/classification.json", "api_surface_template": "/device/classification.json", "params": [], "query_parameter_names": [ "limit", "search" ], "body_shape": null, "statuses": [ 200 ], "content_types": [ "application/json" ], "record_ordinals": [ 41, 42, 43, 52 ] }, { "name": "get_device_enforcement", "method": "GET", "path_template": "/device/enforcement.json", "api_surface_template": "/device/enforcement.json", "params": [], "query_parameter_names": [ "limit", "search", "sort" ], "body_shape": null, "statuses": [ 200 ], "content_types": [ "application/json" ], "record_ordinals": [ 47, 48, 49 ] }, { "name": "get_device_recall", "method": "GET", "path_template": "/device/recall.json", "api_surface_template": "/device/recall.json", "params": [], "query_parameter_names": [ "count", "limit", "search", "sort" ], "body_shape": null, "statuses": [ 200 ], "content_types": [ "application/json" ], "record_ordinals": [ 44, 45, 46 ] }, { "name": "get_drug_drugsfda", "method": "GET", "path_template": "/drug/drugsfda.json", "api_surface_template": "/drug/drugsfda.json", "params": [], "query_parameter_names": [ "limit", "search" ], "body_shape": null, "statuses": [ 200 ], "content_types": [ "application/json" ], "record_ordinals": [ 16, 17, 18, 19 ] }, { "name": "get_drug_enforcement", "method": "GET", "path_template": "/drug/enforcement.json", "api_surface_template": "/drug/enforcement.json", "params": [], "query_parameter_names": [ "count", "limit", "search" ], "body_shape": null, "statuses": [ 200 ], "content_types": [ "application/json" ], "record_ordinals": [ 7, 8, 9, 10, 11, 12, 13, 14, 15, 50 ] }, { "name": "get_drug_ndc", "method": "GET", "path_template": "/drug/ndc.json", "api_surface_template": "/drug/ndc.json", "params": [], "query_parameter_names": [ "limit", "search" ], "body_shape": null, "statuses": [ 200 ], "content_types": [ "application/json" ], "record_ordinals": [ 0, 1, 2, 3, 4, 5, 6, 51 ] }, { "name": "get_drug_shortages", "method": "GET", "path_template": "/drug/shortages.json", "api_surface_template": "/drug/shortages.json", "params": [], "query_parameter_names": [ "limit", "search" ], "body_shape": null, "statuses": [ 200 ], "content_types": [ "application/json" ], "record_ordinals": [ 20, 21, 22, 23, 24 ] }, { "name": "get_food_enforcement", "method": "GET", "path_template": "/food/enforcement.json", "api_surface_template": "/food/enforcement.json", "params": [], "query_parameter_names": [ "count", "limit", "search" ], "body_shape": null, "statuses": [ 200 ], "content_types": [ "application/json" ], "record_ordinals": [ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 ] }, { "name": "get_other_nsde", "method": "GET", "path_template": "/other/nsde.json", "api_surface_template": "/other/nsde.json", "params": [], "query_parameter_names": [ "limit", "search" ], "body_shape": null, "statuses": [ 200 ], "content_types": [ "application/json" ], "record_ordinals": [ 25, 26, 27 ] } ], "records": [ { "ordinal": 0, "method": "GET", "path": "/drug/ndc.json", "status": 200, "content_type": "application/json" }, { "ordinal": 1, "method": "GET", "path": "/drug/ndc.json", "status": 200, "content_type": "application/json" }, { "ordinal": 2, "method": "GET", "path": "/drug/ndc.json", "status": 200, "content_type": "application/json" }, { "ordinal": 3, "method": "GET", "path": "/drug/ndc.json", "status": 200, "content_type": "application/json" }, { "ordinal": 4, "method": "GET", "path": "/drug/ndc.json", "status": 200, "content_type": "application/json" }, { "ordinal": 5, "method": "GET", "path": "/drug/ndc.json", "status": 200, "content_type": "application/json" }, { "ordinal": 6, "method": "GET", "path": "/drug/ndc.json", "status": 200, "content_type": "application/json" }, { "ordinal": 7, "method": "GET", "path": "/drug/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 8, "method": "GET", "path": "/drug/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 9, "method": "GET", "path": "/drug/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 10, "method": "GET", "path": "/drug/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 11, "method": "GET", "path": "/drug/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 12, "method": "GET", "path": "/drug/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 13, "method": "GET", "path": "/drug/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 14, "method": "GET", "path": "/drug/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 15, "method": "GET", "path": "/drug/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 16, "method": "GET", "path": "/drug/drugsfda.json", "status": 200, "content_type": "application/json" }, { "ordinal": 17, "method": "GET", "path": "/drug/drugsfda.json", "status": 200, "content_type": "application/json" }, { "ordinal": 18, "method": "GET", "path": "/drug/drugsfda.json", "status": 200, "content_type": "application/json" }, { "ordinal": 19, "method": "GET", "path": "/drug/drugsfda.json", "status": 200, "content_type": "application/json" }, { "ordinal": 20, "method": "GET", "path": "/drug/shortages.json", "status": 200, "content_type": "application/json" }, { "ordinal": 21, "method": "GET", "path": "/drug/shortages.json", "status": 200, "content_type": "application/json" }, { "ordinal": 22, "method": "GET", "path": "/drug/shortages.json", "status": 200, "content_type": "application/json" }, { "ordinal": 23, "method": "GET", "path": "/drug/shortages.json", "status": 200, "content_type": "application/json" }, { "ordinal": 24, "method": "GET", "path": "/drug/shortages.json", "status": 200, "content_type": "application/json" }, { "ordinal": 25, "method": "GET", "path": "/other/nsde.json", "status": 200, "content_type": "application/json" }, { "ordinal": 26, "method": "GET", "path": "/other/nsde.json", "status": 200, "content_type": "application/json" }, { "ordinal": 27, "method": "GET", "path": "/other/nsde.json", "status": 200, "content_type": "application/json" }, { "ordinal": 28, "method": "GET", "path": "/food/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 29, "method": "GET", "path": "/food/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 30, "method": "GET", "path": "/food/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 31, "method": "GET", "path": "/food/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 32, "method": "GET", "path": "/food/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 33, "method": "GET", "path": "/food/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 34, "method": "GET", "path": "/food/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 35, "method": "GET", "path": "/food/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 36, "method": "GET", "path": "/food/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 37, "method": "GET", "path": "/food/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 38, "method": "GET", "path": "/food/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 39, "method": "GET", "path": "/food/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 40, "method": "GET", "path": "/food/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 41, "method": "GET", "path": "/device/classification.json", "status": 200, "content_type": "application/json" }, { "ordinal": 42, "method": "GET", "path": "/device/classification.json", "status": 200, "content_type": "application/json" }, { "ordinal": 43, "method": "GET", "path": "/device/classification.json", "status": 200, "content_type": "application/json" }, { "ordinal": 44, "method": "GET", "path": "/device/recall.json", "status": 200, "content_type": "application/json" }, { "ordinal": 45, "method": "GET", "path": "/device/recall.json", "status": 200, "content_type": "application/json" }, { "ordinal": 46, "method": "GET", "path": "/device/recall.json", "status": 200, "content_type": "application/json" }, { "ordinal": 47, "method": "GET", "path": "/device/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 48, "method": "GET", "path": "/device/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 49, "method": "GET", "path": "/device/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 50, "method": "GET", "path": "/drug/enforcement.json", "status": 200, "content_type": "application/json" }, { "ordinal": 51, "method": "GET", "path": "/drug/ndc.json", "status": 200, "content_type": "application/json" }, { "ordinal": 52, "method": "GET", "path": "/device/classification.json", "status": 200, "content_type": "application/json" } ], "excluded": [], "templated_groups": 0, "kind": "environment-manifest", "view": { "kind": "environment-manifest", "template_rules": [ "after-uid-literal", "opaque-token", "sibling-variance" ], "include_query_parameter_names": true } }, "confidence": "derived", "authority": "historical-reference", "environment": null, "limitations": [ "A 32 MiB input, 96 MiB reply and 64-level nesting budget bound complete evidence. HAR/SAZ/qlog use a 192 MiB Node old-generation heap; mitmproxy decoding uses a 768 MiB Linux address-space limit. Each owned command has a 30-second deadline with independent cleanup.", "Every record is decoded before selection; no partial success is returned on malformed input or a resource limit.", "HAR text is producer-decoded Unicode. Original body bytes remain unknown unless content explicitly uses valid base64; declared sizes are preserved independently of retained bytes. mitmproxy 12.2.3 SaveHar may report null optional postData.text; that null is retained and omitted only from the upstream validation copy.", "Known authentication headers/cookies and explicitly marked literal values are excluded. Unknown extension names do not establish sensitivity.", "Observed query parameter names do not establish required parameters, value types or a complete API schema.", "Opt-in template rules after-uid-literal, opaque-token, sibling-variance merge recorded literals by shape; merged parameters may conflate distinct resources.", "This is retained producer evidence, without live browser transaction IDs, scenario provenance, execution attribution or deployment authenticity. Recorded URLs are never fetched.", "Tool templates, parameters and names are inferences from recorded request lines; they do not establish handler identity, URL-space schemas or causality." ], "relationship_coverage": null, "locations": [ { "kind": "artifact-path", "path": "/home/ubuntu/capture/openfda/openfda.scoped.har" } ], "evidence_links": [ "ev_831755436c6fab21a1196cc47650cc102eb756bc8286b8c8528cda928dcfaf90" ]}123version https://git-lfs.github.com/spec/v1oid sha256:f7788604b5cc16abf843b394ae24cc5819663dc79e91bb7b4b7b0ae99fe81db0size 60444251234567891011121314tasks = [ "qa-01-get_device_enforcement", "qa-02-get_drug_shortages", "qa-03-get_food_enforcement", "qa-04-get_drug_enforcement", "qa-05-get_device_classification", "qa-06-get_other_nsde", "qa-07-get_drug_drugsfda", "qa-08-get_device_recall", "qa-09-get_drug_ndc", "qa-10-get_device_enforcement", "qa-11-get_drug_shortages", "qa-12-get_food_enforcement",]123456789101112131415161718# Retrieval tasks
Generated from the environment manifest (9 tools) and its capture Evidence. Each task asks one factual question about a recorded record, answerable through one recorded exchange, and is graded deterministically: the response must contain the recorded value. Answers are distinct and appear in at most 12 recorded responses.
| task | tool | arguments | field | answer ||---|---|---|---|---|| `qa-01-get_device_enforcement` | `get_device_enforcement` | search=classification:"Class I", sort=report_date:desc, limit=2 | `results[0].product_quantity` | `771,127 total` || `qa-02-get_drug_shortages` | `get_drug_shortages` | search=status:"Current", limit=2 | `results[0].generic_name` | `Lidocaine Hydrochloride Injection` || `qa-03-get_food_enforcement` | `get_food_enforcement` | search=state:"CO" AND report_date:[20250101 TO 20261231], limit=2 | `results[0].reason_for_recall` | `Package integrity compromised.` || `qa-04-get_drug_enforcement` | `get_drug_enforcement` | search=classification:"Class I" AND status:"Ongoing", limit=3 | `results[0].address_1` | `6555 State Highway 161` || `qa-05-get_device_classification` | `get_device_classification` | search=device_name:"stethoscope", limit=2 | `results[0].device_name` | `Stethoscope, Esophageal` || `qa-06-get_other_nsde` | `get_other_nsde` | search=proprietary_name:"Advil", limit=2 | `results[0].application_number_or_citation` | `NDA018989` || `qa-07-get_drug_drugsfda` | `get_drug_drugsfda` | search=sponsor_name:"PFIZER", limit=1 | `results[0].application_number` | `NDA019617` || `qa-08-get_device_recall` | `get_device_recall` | search=root_cause_description:"Software design", sort=event_date_initiated:desc, limit=1 | `results[0].openfda.medical_specialty_description` | `General, Plastic Surgery` || `qa-09-get_drug_ndc` | `get_drug_ndc` | search=brand_name:"Tylenol", limit=2 | `results[0].labeler_name` | `Kenvue Brands LLC` || `qa-10-get_device_enforcement` | `get_device_enforcement` | search=classification:"Class I", sort=report_date:desc, limit=2 | `results[0].recalling_firm` | `Medline Industries, LP` || `qa-11-get_drug_shortages` | `get_drug_shortages` | search=status:"Current", limit=2 | `results[0].company_name` | `Hospira, Inc., a Pfizer Company` || `qa-12-get_food_enforcement` | `get_food_enforcement` | search=state:"CO" AND report_date:[20250101 TO 20261231], limit=2 | `results[0].code_info` | `BEST BY 14 AUG 2026 and BEST BY 15 AUG 2026` |123456789101112131415161718192021222324252627282930313233343536373839404142[ { "id": "env", "type": "deploy_env", "env_id": "openfda", "sandbox_type": "local" }, { "id": "agent", "type": "deploy_agent", "a2a_agent_id": "replay-qa", "agent_name": "replay-qa", "env_ids": [ "openfda" ], "env_step_id": "env", "sandbox_type": "local" }, { "id": "ask", "type": "prompt_agent", "agent_name": "replay-qa", "prompt_id": "q", "prompt": "In this openFDA environment, look up the device enforcement.json with search classification:\"Class I\" and sort report_date:desc and limit 2 and report its `results[0].product_quantity`. Use only the environment's tools. Answer with the value only, nothing else.", "max_turns": 6 }, { "id": "grade", "type": "agent_prompt_response_verifier", "prompt_id": "q", "verifier_id": "retrieval", "criteria": [ { "type": "response_contains", "criterion": "response states results[0].product_quantity", "needles": [ "771,127 total" ] } ] }]123456789101112131415161718192021222324252627282930313233343536373839404142[ { "id": "env", "type": "deploy_env", "env_id": "openfda", "sandbox_type": "local" }, { "id": "agent", "type": "deploy_agent", "a2a_agent_id": "replay-qa", "agent_name": "replay-qa", "env_ids": [ "openfda" ], "env_step_id": "env", "sandbox_type": "local" }, { "id": "ask", "type": "prompt_agent", "agent_name": "replay-qa", "prompt_id": "q", "prompt": "In this openFDA environment, look up the drug shortages.json with search status:\"Current\" and limit 2 and report its `results[0].generic_name`. Use only the environment's tools. Answer with the value only, nothing else.", "max_turns": 6 }, { "id": "grade", "type": "agent_prompt_response_verifier", "prompt_id": "q", "verifier_id": "retrieval", "criteria": [ { "type": "response_contains", "criterion": "response states results[0].generic_name", "needles": [ "Lidocaine Hydrochloride Injection" ] } ] }]123456789101112131415161718192021222324252627282930313233343536373839404142[ { "id": "env", "type": "deploy_env", "env_id": "openfda", "sandbox_type": "local" }, { "id": "agent", "type": "deploy_agent", "a2a_agent_id": "replay-qa", "agent_name": "replay-qa", "env_ids": [ "openfda" ], "env_step_id": "env", "sandbox_type": "local" }, { "id": "ask", "type": "prompt_agent", "agent_name": "replay-qa", "prompt_id": "q", "prompt": "In this openFDA environment, look up the food enforcement.json with search state:\"CO\" AND report_date:[20250101 TO 20261231] and limit 2 and report its `results[0].reason_for_recall`. Use only the environment's tools. Answer with the value only, nothing else.", "max_turns": 6 }, { "id": "grade", "type": "agent_prompt_response_verifier", "prompt_id": "q", "verifier_id": "retrieval", "criteria": [ { "type": "response_contains", "criterion": "response states results[0].reason_for_recall", "needles": [ "Package integrity compromised." ] } ] }]123456789101112131415161718192021222324252627282930313233343536373839404142[ { "id": "env", "type": "deploy_env", "env_id": "openfda", "sandbox_type": "local" }, { "id": "agent", "type": "deploy_agent", "a2a_agent_id": "replay-qa", "agent_name": "replay-qa", "env_ids": [ "openfda" ], "env_step_id": "env", "sandbox_type": "local" }, { "id": "ask", "type": "prompt_agent", "agent_name": "replay-qa", "prompt_id": "q", "prompt": "In this openFDA environment, look up the drug enforcement.json with search classification:\"Class I\" AND status:\"Ongoing\" and limit 3 and report its `results[0].address_1`. Use only the environment's tools. Answer with the value only, nothing else.", "max_turns": 6 }, { "id": "grade", "type": "agent_prompt_response_verifier", "prompt_id": "q", "verifier_id": "retrieval", "criteria": [ { "type": "response_contains", "criterion": "response states results[0].address_1", "needles": [ "6555 State Highway 161" ] } ] }]123456789101112131415161718192021222324252627282930313233343536373839404142[ { "id": "env", "type": "deploy_env", "env_id": "openfda", "sandbox_type": "local" }, { "id": "agent", "type": "deploy_agent", "a2a_agent_id": "replay-qa", "agent_name": "replay-qa", "env_ids": [ "openfda" ], "env_step_id": "env", "sandbox_type": "local" }, { "id": "ask", "type": "prompt_agent", "agent_name": "replay-qa", "prompt_id": "q", "prompt": "In this openFDA environment, look up the device classification.json with search device_name:\"stethoscope\" and limit 2 and report its `results[0].device_name`. Use only the environment's tools. Answer with the value only, nothing else.", "max_turns": 6 }, { "id": "grade", "type": "agent_prompt_response_verifier", "prompt_id": "q", "verifier_id": "retrieval", "criteria": [ { "type": "response_contains", "criterion": "response states results[0].device_name", "needles": [ "Stethoscope, Esophageal" ] } ] }]123456789101112131415161718192021222324252627282930313233343536373839404142[ { "id": "env", "type": "deploy_env", "env_id": "openfda", "sandbox_type": "local" }, { "id": "agent", "type": "deploy_agent", "a2a_agent_id": "replay-qa", "agent_name": "replay-qa", "env_ids": [ "openfda" ], "env_step_id": "env", "sandbox_type": "local" }, { "id": "ask", "type": "prompt_agent", "agent_name": "replay-qa", "prompt_id": "q", "prompt": "In this openFDA environment, look up the other nsde.json with search proprietary_name:\"Advil\" and limit 2 and report its `results[0].application_number_or_citation`. Use only the environment's tools. Answer with the value only, nothing else.", "max_turns": 6 }, { "id": "grade", "type": "agent_prompt_response_verifier", "prompt_id": "q", "verifier_id": "retrieval", "criteria": [ { "type": "response_contains", "criterion": "response states results[0].application_number_or_citation", "needles": [ "NDA018989" ] } ] }]123456789101112131415161718192021222324252627282930313233343536373839404142[ { "id": "env", "type": "deploy_env", "env_id": "openfda", "sandbox_type": "local" }, { "id": "agent", "type": "deploy_agent", "a2a_agent_id": "replay-qa", "agent_name": "replay-qa", "env_ids": [ "openfda" ], "env_step_id": "env", "sandbox_type": "local" }, { "id": "ask", "type": "prompt_agent", "agent_name": "replay-qa", "prompt_id": "q", "prompt": "In this openFDA environment, look up the drug drugsfda.json with search sponsor_name:\"PFIZER\" and limit 1 and report its `results[0].application_number`. Use only the environment's tools. Answer with the value only, nothing else.", "max_turns": 6 }, { "id": "grade", "type": "agent_prompt_response_verifier", "prompt_id": "q", "verifier_id": "retrieval", "criteria": [ { "type": "response_contains", "criterion": "response states results[0].application_number", "needles": [ "NDA019617" ] } ] }]123456789101112131415161718192021222324252627282930313233343536373839404142[ { "id": "env", "type": "deploy_env", "env_id": "openfda", "sandbox_type": "local" }, { "id": "agent", "type": "deploy_agent", "a2a_agent_id": "replay-qa", "agent_name": "replay-qa", "env_ids": [ "openfda" ], "env_step_id": "env", "sandbox_type": "local" }, { "id": "ask", "type": "prompt_agent", "agent_name": "replay-qa", "prompt_id": "q", "prompt": "In this openFDA environment, look up the device recall.json with search root_cause_description:\"Software design\" and sort event_date_initiated:desc and limit 1 and report its `results[0].openfda.medical_specialty_description`. Use only the environment's tools. Answer with the value only, nothing else.", "max_turns": 6 }, { "id": "grade", "type": "agent_prompt_response_verifier", "prompt_id": "q", "verifier_id": "retrieval", "criteria": [ { "type": "response_contains", "criterion": "response states results[0].openfda.medical_specialty_description", "needles": [ "General, Plastic Surgery" ] } ] }]123456789101112131415161718192021222324252627282930313233343536373839404142[ { "id": "env", "type": "deploy_env", "env_id": "openfda", "sandbox_type": "local" }, { "id": "agent", "type": "deploy_agent", "a2a_agent_id": "replay-qa", "agent_name": "replay-qa", "env_ids": [ "openfda" ], "env_step_id": "env", "sandbox_type": "local" }, { "id": "ask", "type": "prompt_agent", "agent_name": "replay-qa", "prompt_id": "q", "prompt": "In this openFDA environment, look up the drug ndc.json with search brand_name:\"Tylenol\" and limit 2 and report its `results[0].labeler_name`. Use only the environment's tools. Answer with the value only, nothing else.", "max_turns": 6 }, { "id": "grade", "type": "agent_prompt_response_verifier", "prompt_id": "q", "verifier_id": "retrieval", "criteria": [ { "type": "response_contains", "criterion": "response states results[0].labeler_name", "needles": [ "Kenvue Brands LLC" ] } ] }]123456789101112131415161718192021222324252627282930313233343536373839404142[ { "id": "env", "type": "deploy_env", "env_id": "openfda", "sandbox_type": "local" }, { "id": "agent", "type": "deploy_agent", "a2a_agent_id": "replay-qa", "agent_name": "replay-qa", "env_ids": [ "openfda" ], "env_step_id": "env", "sandbox_type": "local" }, { "id": "ask", "type": "prompt_agent", "agent_name": "replay-qa", "prompt_id": "q", "prompt": "In this openFDA environment, look up the device enforcement.json with search classification:\"Class I\" and sort report_date:desc and limit 2 and report its `results[0].recalling_firm`. Use only the environment's tools. Answer with the value only, nothing else.", "max_turns": 6 }, { "id": "grade", "type": "agent_prompt_response_verifier", "prompt_id": "q", "verifier_id": "retrieval", "criteria": [ { "type": "response_contains", "criterion": "response states results[0].recalling_firm", "needles": [ "Medline Industries, LP" ] } ] }]123456789101112131415161718192021222324252627282930313233343536373839404142[ { "id": "env", "type": "deploy_env", "env_id": "openfda", "sandbox_type": "local" }, { "id": "agent", "type": "deploy_agent", "a2a_agent_id": "replay-qa", "agent_name": "replay-qa", "env_ids": [ "openfda" ], "env_step_id": "env", "sandbox_type": "local" }, { "id": "ask", "type": "prompt_agent", "agent_name": "replay-qa", "prompt_id": "q", "prompt": "In this openFDA environment, look up the drug shortages.json with search status:\"Current\" and limit 2 and report its `results[0].company_name`. Use only the environment's tools. Answer with the value only, nothing else.", "max_turns": 6 }, { "id": "grade", "type": "agent_prompt_response_verifier", "prompt_id": "q", "verifier_id": "retrieval", "criteria": [ { "type": "response_contains", "criterion": "response states results[0].company_name", "needles": [ "Hospira, Inc., a Pfizer Company" ] } ] }]123456789101112131415161718192021222324252627282930313233343536373839404142[ { "id": "env", "type": "deploy_env", "env_id": "openfda", "sandbox_type": "local" }, { "id": "agent", "type": "deploy_agent", "a2a_agent_id": "replay-qa", "agent_name": "replay-qa", "env_ids": [ "openfda" ], "env_step_id": "env", "sandbox_type": "local" }, { "id": "ask", "type": "prompt_agent", "agent_name": "replay-qa", "prompt_id": "q", "prompt": "In this openFDA environment, look up the food enforcement.json with search state:\"CO\" AND report_date:[20250101 TO 20261231] and limit 2 and report its `results[0].code_info`. Use only the environment's tools. Answer with the value only, nothing else.", "max_turns": 6 }, { "id": "grade", "type": "agent_prompt_response_verifier", "prompt_id": "q", "verifier_id": "retrieval", "criteria": [ { "type": "response_contains", "criterion": "response states results[0].code_info", "needles": [ "BEST BY 14 AUG 2026 and BEST BY 15 AUG 2026" ] } ] }]123456789101112131415[ { "id": "env", "type": "deploy_env", "env_id": "openfda", "sandbox_type": "local" }, { "id": "replay", "type": "env_outcome_verifier", "env_id": "openfda", "file_artifact_id": "check_openfda", "verifier_id": "replay" }]123version https://git-lfs.github.com/spec/v1oid sha256:5578aa52cfa88270bbc88df50421873574cd4548039caff3ff228dfbffa7cc06size 38276123version https://git-lfs.github.com/spec/v1oid sha256:d8b8007f8f2e7fab2751e44b5a4b58d7c41504573d0bf9e61211db35ea971259size 9552README.mdAdded+141
bundles/openfda/README.mdAdded+46
bundles/openfda/agents/replay-qa/DockerfileAdded+9
bundles/openfda/agents/replay-qa/README.mdAdded+51
bundles/openfda/agents/replay-qa/agent.pyAdded+284
bundles/openfda/agents/replay-qa/agent.tomlAdded+5
bundles/openfda/artifacts/check_openfda/verify.pyAdded+37
bundles/openfda/envs/openfda/DockerfileAdded+9
bundles/openfda/envs/openfda/env.tomlAdded+1
bundles/openfda/envs/openfda/evidence.jsonAdded
bundles/openfda/envs/openfda/manifest.jsonAdded+724
bundles/openfda/envs/openfda/rea-agents.tgzAdded+3
bundles/openfda/evals/openfda-retrieval.tomlAdded+14
bundles/openfda/tasks/INDEX.mdAdded+18
bundles/openfda/tasks/qa-01-get_device_enforcement.jsonAdded+42
bundles/openfda/tasks/qa-02-get_drug_shortages.jsonAdded+42
bundles/openfda/tasks/qa-03-get_food_enforcement.jsonAdded+42
bundles/openfda/tasks/qa-04-get_drug_enforcement.jsonAdded+42
bundles/openfda/tasks/qa-05-get_device_classification.jsonAdded+42
bundles/openfda/tasks/qa-06-get_other_nsde.jsonAdded+42
bundles/openfda/tasks/qa-07-get_drug_drugsfda.jsonAdded+42
bundles/openfda/tasks/qa-08-get_device_recall.jsonAdded+42
bundles/openfda/tasks/qa-09-get_drug_ndc.jsonAdded+42
bundles/openfda/tasks/qa-10-get_device_enforcement.jsonAdded+42
bundles/openfda/tasks/qa-11-get_drug_shortages.jsonAdded+42
bundles/openfda/tasks/qa-12-get_food_enforcement.jsonAdded+42
bundles/openfda/tasks/smoke.jsonAdded+15
episodes/openfda.parquetAdded+3
raw/openfda.jsonlAdded
tasks/openfda.parquetAdded+3