AttractorEx.Agent.* implements a spec-inspired coding-agent session model on top of the unified LLM client.
Main Modules
AttractorEx.Agent.BuiltinToolsAttractorEx.Agent.SessionAttractorEx.Agent.SessionConfigAttractorEx.Agent.ProviderProfileAttractorEx.Agent.ToolAttractorEx.Agent.ToolCallAttractorEx.Agent.ToolResultAttractorEx.Agent.ToolRegistryAttractorEx.Agent.ExecutionEnvironmentAttractorEx.Agent.LocalExecutionEnvironment
Responsibilities
AttractorEx.Agent.Session owns the loop:
- build a provider-aligned request
- send it through
AttractorEx.LLM.Client - normalize tool calls
- execute tools with timeouts and truncation rules
- feed tool results back into the next round
The session layer is deliberately conservative: it focuses on determinism, bounded output, and operational safety rather than full parity with every upstream provider feature.
Event Surface
AttractorEx.Agent.Session now emits a typed event stream through AttractorEx.Agent.Event.
Implemented event kinds include:
session_startsession_enduser_inputassistant_text_startassistant_text_deltaassistant_text_endtool_call_starttool_call_output_deltatool_call_endsteering_injectedturn_limitloop_detectionerror
For non-streaming Client.complete/2 responses and synchronous tool execution, the session synthesizes single-chunk delta events so host applications can still consume a consistent event surface. tool_call_end carries the full untruncated tool output for UI/logging integrations, while the model continues to receive the bounded/truncated tool result stored in conversation history.
Provider Profiles
AttractorEx.Agent.ProviderProfile packages:
- a provider ID
- a model name
- provider capability metadata such as reasoning support, streaming support, parallel tool-call support, and context-window size
- tool definitions
- provider options
- a system prompt builder
This keeps the agent loop portable across LLM providers while letting each integration choose its own prompt and tool behavior.
Convenience presets are available for the common coding-agent providers:
ProviderProfile.openai/1ProviderProfile.anthropic/1ProviderProfile.gemini/1
Those presets attach provider-aligned built-in tool bundles and default capability metadata so applications do not need to rebuild the baseline profile shape manually.
ProviderProfile.integration_matrix/0 exposes the maintained cross-provider compatibility matrix for:
- implemented tool names
- upstream reference tool names
- capability flags
- provider-specific instruction files
- reasoning/thinking option paths
- shared session event kinds
Execution Environment
The environment contract now includes the local tool surface used by the coding-agent loop:
working_directory/1platform/1read_file/2write_file/3list_directory/2glob/2grep/3shell_command/3environment_context/1
AttractorEx.Agent.LocalExecutionEnvironment is the default implementation used in tests and local sessions.
Built-In Tools
AttractorEx.Agent.BuiltinTools exposes a provider-neutral baseline toolset under the :default preset:
read_filewrite_filelist_directoryglobgrepshell_commandspawn_agentsend_inputwaitclose_agent
Provider presets now swap in provider-native tool names where the upstream agent harness differs:
- OpenAI:
apply_patch,shell - Anthropic:
edit_file,shell - Gemini:
read_many_files,edit_file,shell,list_dir
Filesystem and shell tools are backed by the execution-environment behaviour, so alternative environments can swap in sandboxed or remote implementations without changing the session loop. The OpenAI-facing apply_patch tool is available for local sessions through AttractorEx.Agent.ApplyPatch. Subagent tools are session-managed and create child AttractorEx.Agent.Session instances that keep independent history while sharing the parent's execution environment.
Subagents
The coding-agent loop now implements the spec's subagent lifecycle:
spawn_agentcreates a child session, inherits the parent profile/tool bundle, optionally overrides model, working directory, andmax_turns, and immediately runs the scoped tasksend_inputcontinues an existing child session with another messagewaitreturns a JSON payload containing subagent output, success, and turns usedclose_agentremoves the child session from the active subagent map
Subagents inherit the parent's execution environment and are depth-limited by SessionConfig.max_subagent_depth (default 1).
Prompt Context
The default system-prompt builder now includes:
- working directory and platform
- provider/model metadata
- available tool names
- serialized environment context
- project instruction files discovered from the working directory ancestry
Project instruction discovery loads AGENTS.md plus provider-specific files such as CODEX.md, CLAUDE.md, GEMINI.md, and .codex/instructions.md when present.
Compliance Status
The local coding-agent compliance guide tracks implemented and missing areas relative to the upstream coding-agent loop specification. Read the Coding Agent Loop Compliance reference for the detailed matrix.