From 058aa0f767886eb1173970dbf308d473885adff8 Mon Sep 17 00:00:00 2001 From: Richard Abrich Date: Sun, 29 Mar 2026 13:56:08 -0400 Subject: [PATCH] feat: add openadapt-types dependency and _AgentOutput schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add openadapt-types>=0.1.0 to core dependencies (canonical action schema for the OpenAdapt ecosystem — Pydantic v2, lightweight) - Add _AgentOutput Pydantic model for future Outlines JSON schema constrained decoding (currently unused — default is DSL regex) - Does NOT change the system prompt (DSL format, matching #236 fix) The _AgentOutput model enables switching to outlines.json(model, schema) once models are SFT'd on JSON format. For now, DSL regex remains default. Co-Authored-By: Claude Opus 4.6 (1M context) --- openadapt_evals/training/trl_rollout.py | 26 ++++++++++++++++++++++++- pyproject.toml | 2 ++ uv.lock | 16 ++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/openadapt_evals/training/trl_rollout.py b/openadapt_evals/training/trl_rollout.py index a094b68..5d24090 100644 --- a/openadapt_evals/training/trl_rollout.py +++ b/openadapt_evals/training/trl_rollout.py @@ -71,7 +71,9 @@ import logging import re import time -from typing import Any, Callable +from typing import Any, Callable, Optional + +from pydantic import BaseModel from openadapt_evals.adapters.base import BenchmarkAction, BenchmarkObservation from openadapt_evals.adapters.rl_env import RLEnvironment, ResetConfig @@ -99,6 +101,28 @@ ACTION_REGEX = r"Thought: [^\n]+\nAction: (" + _ACTION_RE + r")" +# --------------------------------------------------------------------------- +# JSON schema for future Outlines JSON-mode constrained decoding +# --------------------------------------------------------------------------- +# When the model is SFT'd on JSON format (not DSL), switch constrained +# decoding to: outlines.json(model, _AgentOutput) instead of regex. +# This is NOT the default — the default uses DSL regex (ACTION_REGEX). +class _AgentOutput(BaseModel): + """Pydantic schema for Outlines JSON-mode constrained decoding. + + Use with: ``outlines.json(model, _AgentOutput)`` once the model has + been SFT'd on JSON action format. Currently unused — default is DSL + regex via ACTION_REGEX. + """ + + reasoning: str + type: str # click, type, key, scroll, wait, done + x: Optional[float] = None + y: Optional[float] = None + text: Optional[str] = None + key: Optional[str] = None + + def _build_outlines_generator(model: Any, processor: Any) -> Any | None: """Build an Outlines Generator for constrained generation. diff --git a/pyproject.toml b/pyproject.toml index f9d2881..356ea48 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,7 @@ dependencies = [ "pyyaml>=6.0", "openadapt-consilium>=0.3.2", "openadapt-telemetry>=0.2.0", + "openadapt-types>=0.1.0", ] [project.optional-dependencies] @@ -148,6 +149,7 @@ Documentation = "https://github.com/OpenAdaptAI/openadapt-evals#readme" [tool.uv.sources] openadapt-consilium = { git = "https://github.com/OpenAdaptAI/openadapt-consilium.git" } openadapt-ml = { path = "../openadapt-ml", editable = true } +openadapt-types = { path = "../openadapt-types", editable = true } [tool.hatch.build.targets.wheel] packages = ["openadapt_evals", "scripts"] diff --git a/uv.lock b/uv.lock index c1eeca4..b12d6fd 100644 --- a/uv.lock +++ b/uv.lock @@ -3311,13 +3311,14 @@ wheels = [ [[package]] name = "openadapt-evals" -version = "0.80.0" +version = "0.80.2" source = { editable = "." } dependencies = [ { name = "anthropic" }, { name = "httpx" }, { name = "openadapt-consilium" }, { name = "openadapt-telemetry" }, + { name = "openadapt-types" }, { name = "openai" }, { name = "pillow" }, { name = "pydantic-settings" }, @@ -3429,6 +3430,7 @@ requires-dist = [ { name = "openadapt-ml", extras = ["training"], marker = "extra == 'training'", specifier = ">=0.11.0" }, { name = "openadapt-retrieval", marker = "extra == 'retrieval'", specifier = ">=0.1.0" }, { name = "openadapt-telemetry", specifier = ">=0.2.0" }, + { name = "openadapt-types", specifier = ">=0.1.0" }, { name = "openai", specifier = ">=1.0.0" }, { name = "outlines", marker = "extra == 'dev'", specifier = ">=0.1.0" }, { name = "outlines", marker = "extra == 'training'", specifier = ">=0.1.0" }, @@ -3513,6 +3515,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/18/5c/7d5c802610f37d5f48b1d1f55e5406fb672b69f8339ba9055416016bf3c9/openadapt_telemetry-0.2.0-py3-none-any.whl", hash = "sha256:64d3e638dde99a0ce6a0735d191da18a9b321dc11965dcb80137ff9948d55a42", size = 22691 }, ] +[[package]] +name = "openadapt-types" +version = "0.1.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pydantic" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/33/97/47fce6b5e296b4fe5a627ce59fc87de40619c216e8102f91357299b3bbda/openadapt_types-0.1.0.tar.gz", hash = "sha256:e2b62b00c5a9a3769b81aa74cafc8ac2f358d6956aef2e950cb966f24f621ddc", size = 43269 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2e/8f/bf543b8351694cbc4bd5d34ef96ecfe8eb16e1fbf8da3584f8fe799c67e5/openadapt_types-0.1.0-py3-none-any.whl", hash = "sha256:2de4868ad1de6392ab0e1fc0239f7a3e00db804ea5f9a7309294700f4a3e0387", size = 15280 }, +] + [[package]] name = "openai" version = "2.29.0"