Skip to content

Skeleton PR: Agentic Environment for Tool Synthesis#2358

Draft
aniruddh-alt wants to merge 23 commits intomainfrom
aniruddh-alt/agent-environment-skeleton
Draft

Skeleton PR: Agentic Environment for Tool Synthesis#2358
aniruddh-alt wants to merge 23 commits intomainfrom
aniruddh-alt/agent-environment-skeleton

Conversation

@aniruddh-alt
Copy link
Copy Markdown
Contributor

@aniruddh-alt aniruddh-alt commented Apr 9, 2026

Summary

  • Introduces oumi/environments/ as a first-class top-level package (alongside oumi/inference/) for simulated agent environments — usable by synthesis, evaluation, and RL
  • Each environment type (StatefulEnvironment, StatelessEnvironment, DeterministicEnvironment) owns its typed tool subclass (StatefulTool, StatelessTool, DeterministicTool), co-located in the same file
  • BaseEnvironment ABC with __init_subclass__ registry, typed tool coercion, and create() factory
  • BaseTool base class with common fields; environment-specific fields live only on the relevant subclass
  • DeterministicEnvironment.resolve() and StatelessEnvironment.resolve_cached()/cache_result() — environments own tool execution, not a separate executor
  • EnvironmentConfig as the reusable top-level container, referenced by SynthesisConfig (inline or via environment_config_path)
  • Strict validation: BaseEnvironment.create() requires explicit type, EnvironmentConfig.resolve_tools() raises on unknown ids

Test plan

  • 40 unit tests passing (tool params + synthesis config)
  • pyright 0 errors on all changed files
  • ruff clean
  • Verify YAML serialization round-trip for EnvironmentConfig
  • Integration test: create environments from YAML, resolve tools through SynthesisConfig

Summary by Gitar

  • New environments package: Added oumi/environments/ as top-level package with BaseEnvironment, BaseTool, and three typed environment classes (StatefulEnvironment, StatelessEnvironment, DeterministicEnvironment) owning their tool subclasses.
  • Config integration: Added EnvironmentConfig for reusable tool catalogs, integrated into SynthesisConfig via environment_config or environment_config_path; added MultiTurnAttribute.available_environments and available_tools fields.
  • Synthesis enhancements: ConversationSynthesizer now accepts environment_config; SynthesisPipeline filters samples missing required multiturn outputs.
  • Validation and factories: BaseEnvironment.create() factory with __init_subclass__ registry; EnvironmentConfig.resolve_tools() with strict validation; 40 unit tests for tool params and synthesis config.
  • Documentation: Added user guide section on environment-first tool synthesis with YAML examples.

This will update automatically on new commits.

aniruddh-alt and others added 9 commits April 1, 2026 20:34
Establishes the public API surface for tool-based conversation synthesis:
- ToolAttribute, ToolEnvironmentAttribute config dataclasses with validation
- ToolExecutor stub (parsing, execution, output formatting)
- GeneratedToolEnvironment + EnvironmentRegistry stubs (stateful tools)
- json_patch utility stub (RFC 6902)
- MultiTurnAttribute extended with available_tools/max_tool_calls_per_turn
- jsonpatch dependency added to pyproject.toml

All new modules contain signatures only (raise NotImplementedError).
Implementations follow in subsequent PRs.
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…archy

Restructure the agentic environment skeleton to follow an
environment-first ownership model:

- Create `oumi/environments/` as a first-class top-level package
  (alongside `oumi/inference/`) for use by synthesis, evaluation, and RL
- Each environment file co-locates its typed tool subclass:
  DeterministicEnvironment + DeterministicTool, StatefulEnvironment +
  StatefulTool, StatelessEnvironment + StatelessTool
- Replace the monolithic ToolAttribute with BaseTool + typed subclasses
  that carry only fields relevant to their environment type
- Remove ToolExecutor from environments (synthesis-specific concern)
- Environments own tool resolution: DeterministicEnvironment.resolve(),
  StatelessEnvironment.resolve_cached()/cache_result()
- BaseEnvironment.create() now requires 'type' explicitly (no silent
  default to stateful)
- EnvironmentConfig.resolve_tools() raises on unknown ids instead of
  silently returning empty lists
- Config layer no longer imports from synthesis runtime
Add type annotations to test helper functions, type-ignore comments
for intentionally invalid kwargs in negative tests, and None guards
for optional fields.
@gitar-bot
Copy link
Copy Markdown

gitar-bot bot commented Apr 9, 2026

Gitar is working

Gitar

@aniruddh-alt aniruddh-alt changed the title refactor: environment-first architecture for agentic tool synthesis Skeleton PR: Agentic Environment for Tool Synthesis Apr 9, 2026
@aniruddh-alt aniruddh-alt self-assigned this Apr 9, 2026
Comment thread src/oumi/core/configs/environment_config.py Fixed
@aniruddh-alt aniruddh-alt requested a review from jgreer013 April 9, 2026 05:09
Comment thread src/oumi/mcp/job_logs.py Outdated
Comment thread src/oumi/mcp/job_launcher.py Outdated
Comment thread src/oumi/environments/stateless_environment.py Outdated
Comment thread src/oumi/environments/stateless_environment.py Outdated
Comment thread src/oumi/environments/stateless_environment.py Outdated
Comment thread src/oumi/environments/base_environment.py Outdated
class EnvironmentConfig(BaseConfig):
"""Top-level config for environment-first tool definitions."""

environments: list[Any] = field(default_factory=list)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This typing is a bit too weak

Comment thread src/oumi/core/configs/environment_config.py
Comment thread docs/user_guides/synth.md
Comment thread docs/user_guides/synth.md Outdated
Comment thread src/oumi/core/configs/environment_config.py Fixed
Move ToolResult from its own file into base_tool.py alongside Tool and
DeterministicToolOutput — all tool-related data types now live in one
place. Restore lazy loading of EnvironmentConfig and SynthesisConfig
in oumi.core.configs.__init__ to prevent circular imports when
oumi.environments is imported first.
Move EnvironmentConfig, BaseEnvironment, and Tool imports behind
TYPE_CHECKING in synthesis_config.py since they are only used for
type annotations. The single runtime usage of EnvironmentConfig
(from_yaml call) uses a local import. Remove the __getattr__
lazy-loading hack from oumi.core.configs.__init__ and restore
SynthesisConfig as a normal re-export.
Comment thread src/oumi/core/configs/environment_config.py Dismissed
aniruddh-alt and others added 2 commits April 14, 2026 14:47
OmegaConf resolves dataclass field annotations at runtime via
get_type_hints(). With EnvironmentConfig behind TYPE_CHECKING,
the annotation string cannot be resolved, breaking YAML parsing.
Use Any for the runtime annotation while keeping the TYPE_CHECKING
import for static analysis.
Extract tool parameter and output schemas into a dedicated ToolSchema
class with validation and serialization. Update Tool to use ToolSchema
for parameters and add optional output_schema field.
aniruddh-alt

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants