Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/core/env_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""Core environment interfaces and types."""

from .base_transforms import CompositeTransform, NullTransform
from .code_execution_environment import CodeExecutionEnvironment
from .interfaces import Environment, Transform
from .types import (
Action,
Expand All @@ -34,6 +33,4 @@
# Base transforms
"CompositeTransform",
"NullTransform",
# Base environment implementation
"CodeExecutionEnvironment",
]
167 changes: 0 additions & 167 deletions src/core/env_server/code_execution_environment.py

This file was deleted.

74 changes: 0 additions & 74 deletions src/core/env_server/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

import traceback
from dataclasses import dataclass, field
from typing import Any, Dict, List, Optional, Union

Expand All @@ -20,57 +19,6 @@ class Action:
metadata: Dict[str, Any] = field(default_factory=dict)


@dataclass(kw_only=True)
class CodeAction(Action):
"""Action containing Python code to execute in a CodeAct environment."""

code: str

def __post_init__(self):
if not self.code or not self.code.strip():
raise ValueError("code is required and cannot be empty")


@dataclass
class ExecutionResult:
"""Result of executing Python code."""

stdout: str = ""
stderr: str = ""
exit_code: int = 0
execution_time_ms: float = 0.0

@classmethod
def from_exception(
cls, exc: Exception, stdout: str = "", stderr: str = ""
) -> "ExecutionResult":
return cls(
stdout=stdout,
stderr=stderr,
exception=exc,
exception_type=exc.__class__.__name__,
exception_message=str(exc),
traceback_str=traceback.format_exc(),
success=False,
)

@classmethod
def from_success(
cls,
return_value: Any = None,
stdout: str = "",
stderr: str = "",
execution_time_ms: float = 0.0,
) -> "ExecutionResult":
return cls(
stdout=stdout,
stderr=stderr,
return_value=return_value,
execution_time_ms=execution_time_ms,
success=True,
)


@dataclass(kw_only=True)
class Observation:
"""Base class for all environment observations."""
Expand All @@ -80,31 +28,9 @@ class Observation:
metadata: Dict[str, Any] = field(default_factory=dict)


@dataclass(kw_only=True)
class CodeObservation(Observation):
"""Observation from CodeAct environment execution."""

execution_result: ExecutionResult = field(default_factory=ExecutionResult)
available_tools: List[str] = field(default_factory=list)


@dataclass
class State:
"""Base class for environment state."""

episode_id: Optional[str] = None
step_count: int = 0
metadata: Dict[str, Any] = field(default_factory=dict)


@dataclass
class CodeState(State):
"""State for CodeAct environment with persistent execution context."""

execution_globals: Dict[str, Any] = field(default_factory=dict)
action_history: List[CodeAction] = field(default_factory=list)
result_history: List[ExecutionResult] = field(default_factory=list)

def __post_init__(self):
if not self.execution_globals:
self.execution_globals = {"__builtins__": __builtins__}
2 changes: 1 addition & 1 deletion src/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

"""Environment implementations."""
"""This module encapsulates all environment implementations."""

from .coding import CodingEnv

Expand Down
21 changes: 0 additions & 21 deletions src/envs/coding/__init__.py

This file was deleted.

51 changes: 0 additions & 51 deletions src/envs/coding/coding_env.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from core.base_env_client import HTTPEnvClient
from core.types import StepResult

from .models import CodeAction, CodeObservation
from ..models import CodeAction, CodeObservation


class CodingEnv(HTTPEnvClient[CodeAction, CodeObservation]):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from envs.coding_env.env import CodingEnv
from envs.coding_env.models import CodeAction

from .coding_env_client import CodingEnv

env = CodingEnv(base_url="http://localhost:8080")
obs0 = env.reset()
result = env.step(CodeAction(code="print('hi')"))
Expand Down
Loading