feat(agentenv-wrapper): Generic tool-based wrapper for AgentGym environments #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces
agentenv-wrapper, a generic package for adapting AgentGym environments into tool-based interfaces suitable for LLM agent frameworks like LangChain.This addresses the feedback on PR WooooDyy#68 (WooooDyy/AgentGym) where @SixPlusSeven67 suggested creating a consistent mapping from existing AgentEnvironments to tools, rather than just demonstrating the MCP server pattern.
Architecture
flowchart TB subgraph Agent["Agent Framework"] LC[LangChain Agent] CA[Custom Agent] end subgraph Wrapper["AgentEnv Wrapper"] BTW[BaseToolWrapper] TEW[ToolEnvironmentWrapper] subgraph Adapters BAW[BabyAIToolWrapper] WSW[WebShopToolWrapper] CW["..."] end subgraph LCI["LangChain Integration"] CLT[create_langchain_tools] CAE[create_agent_for_env] AER[AgentEnvRunner] end end subgraph Servers["AgentGym Environment Servers"] BS[BabyAI Server] WS[WebShop Server] OS["..."] end LC --> CLT CA --> BTW CLT --> BAW CAE --> BAW BAW --> BS TEW --> WS TEW --> OSChanges
Core Components
models.py: Data models (ActionTool, ToolDefinition, ToolResult, EnvState)base.py: BaseToolWrapper abstract class and ToolEnvironmentWrapperadapters/babyai.py: BabyAI-specific adapter with action parsingLangChain Integration
langchain/tools.py: Convert wrapper tools to LangChain toolslangchain/agent.py: create_agent_for_env() using v1 syntax (initialize_agent)AgentEnvRunner: Episode runner with batch support and metricsExamples & Tests
examples/babyai_langchain_example.py: Full usage examplestests/: Unit tests for models and wrappersKey Design Decisions
initialize_agentinstead ofcreate_react_agentfor broader compatibilityUsage Example
Type of Change
Testing
Checklist
Related