Agent framework 2 - #57
Merged
Merged
Conversation
…oggingCallback - New crate `potato-spec` with PotatoSpec/AgentSpec/WorkflowSpec deserialization structs - SpecError with 7 variants for clear load-time error messages - LoggingCallback added to potato-agent for built-in tracing support - Workspace and potato-head facade wired up Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…uction - SpecLoader with tool/callback registry for declarative agent loading - Builds Agent, SequentialAgent, ParallelAgent, and DAG Workflow from YAML - Topological sort for DAG tasks with cycle detection - 18 tests covering deserialization, error paths, and sort correctness - LoggingCallback available as built-in callback type Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request
Short summary
Adds the full agent execution engine to
potato_agentand a newpotato_speccrate for loading agents and workflows from YAML. The crate previously hadAgent,Task, andTaskStatus. Everything else was missing.Context
potato_agentAgentBuilderis a fluent builder forArc<Agent>. It takes provider, model, system prompt, sync and async tools, sub-agents, memory, completion criteria, and callbacks. It's the main construction path for everything that follows.Completion criteria plug in via
CompletionCriteria. Three built-ins:MaxIterationsCriteria,KeywordCriteria(stops when the response contains a given string),StructuredOutputCriteria(stops when the response is valid JSON, optionally checked against a schema). You can combine them — all must pass to stop.Lifecycle callbacks fire at
before_model_call,after_model_call,before_tool_call, andafter_tool_call.LoggingCallbackis built in and usestracing::info!on all four. Custom implementations come in asArc<dyn AgentCallback>.Three memory backends:
InMemoryMemory(unbounded),WindowedMemory(last N turns),PersistentMemory(backed by anyMemoryStoreimpl, with optional windowing). SQLite implementations for all four store traits are gated behindfeature = "sqlite"and scoped by(app_name, user_id, session_id).Orchestration:
SequentialAgentruns A → B → C with optionalpass_outputto feed each agent the previous response.ParallelAgentspawns viatokio::spawnand merges withMergeStrategy::CollectAllorFirst. Both implementAgentRunnerand can be nested.AgentToolwraps anyAgentRunneras an async tool so agents can call other agents through the standard tool-use loop.SessionState/SessionSnapshotis a scoped key-value map shared across runs. Parallel child sessions merge user data back into the parent after joining.potato_spec— new crateLoad agents and workflows from YAML instead of writing builder code. Pre-register
Arc<dyn AsyncTool>andArc<dyn AgentCallback>by name, then callload_file(). DAG workflows run topological sort before inserting tasks, so out-of-order declarations work and circular dependencies fail with a clear error at load time rather than at runtime.Three entry points:
SpecLoader::from_spec(yaml)— parse from stringSpecLoader::from_spec_path(path)— read from fileSpecLoader::new().register_async_tool(...).register_callback(...).load_file(path)— with pre-registered tools/callbacksBefore:
After:
Tests
9 new test modules in
baked_potatoagainst the mock LLM server, 18 tests inpotato_spec:agent/agentic_loop_test.rsagent/builder_test.rsagent/callbacks_test.rsLoggingCallbackagent/criteria_test.rsagent/memory_test.rsagent/orchestration_test.rspass_output), parallel (both merge strategies)agent/session_test.rsagent/store_test.rsagent/tool_ext_test.rsAgentToolcomposition,AgentToolPolicycrates/potato_spec/tests/load_spec.rsDocs
7 MkDocs pages covering agents overview, memory, criteria, callbacks, orchestration, session state, and tools.
crates/potato_agent/src/agents/builder.rsAgentBuilder(292 lines)crates/potato_agent/src/agents/callbacks.rsAgentCallbacktrait +LoggingCallbackcrates/potato_agent/src/agents/criteria.rsCompletionCriteriaimplementationscrates/potato_agent/src/agents/memory/InMemoryMemory,WindowedMemory,PersistentMemorycrates/potato_agent/src/agents/orchestration/SequentialAgent,ParallelAgent+ builderscrates/potato_agent/src/agents/session.rsSessionState/SessionSnapshotcrates/potato_agent/src/agents/store/crates/potato_agent/src/agents/tool_ext.rsAgentTool,AgentToolPolicycrates/potato_agent/src/lib.rscrates/potato_spec/src/SpecLoader,LoadedSpec,SpecError, spec structscrates/potato_spec/tests/crates/potato_head/src/lib.rsSpecLoader,LoadedSpec,SpecError,PotatoSpeccrates/baked_potato/tests/agent/py-potato/docs/docs/agents/crates/potato_type/src/tools/AsyncTooltrait, tool type additionsCargo.tomlpotato-specadded to workspaceIs this a breaking change?
No.
Agent,Task,TaskStatus,AgentError, andGenAiClientare unchanged.potato_headgains re-exports that don't affect existing imports.