feat(energy): compose the starter agent's toolbelt inline in the notebook#164
Merged
Conversation
…book Replace the starter agent's boolean toggles (enable_search / enable_code_exec) with an explicit tools=[...] toolbelt, so the notebook shows how an agent is assembled — a persona plus a list of tools — instead of hiding it behind flags. - New starter_agent/tools.py: a ToolSpec descriptor plus one factory per tool (news_search, code_sandbox, arima_forecast). Each spec carries the config fragment it fills, its playbook skill, prompt supplement, and token floor. - build_starter_agent_config now folds a Sequence[ToolSpec] onto AgentConfig, routing each fragment to the right field. The plumbing stays in the module; the notebook composition is comment-a-line-to-toggle. - Wires the previously demo-only ForecastTool (AutoARIMA run_forecast) into the starter agent via arima_forecast() — the agent can now call a statistical forecast directly, no code-gen. arima_forecast() accepts a data_service and series_id/frequency so it generalizes beyond WTI. - 99_starter_agent.ipynb §1 and §4 updated to the toolbelt model; add-a-tool step now points at tools.py instead of the analyst_agent reference. - test_starter_agent.py pins the fold: each factory routes to exactly one AgentConfig field, and composition/order are order-independent. Co-Authored-By: Claude Opus 4.8 <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.
What & why
The starter agent (
99_starter_agent.ipynb) hid its capabilities behind boolean toggles (enable_search,enable_code_exec), which obscured the one thing worth teaching: an agent is a persona plus a list of tools you assemble. This PR makes that list the thing you edit, right in the notebook.It also wires in the previously demo-only
ForecastTool(AutoARIMArun_forecast) — the affordance that lets an agent call a statistical forecast directly, without writing forecasting code. Until now no starter/adaptive agent had it in its toolset; nowarima_forecast()puts it one line away.Scoped to
implementations/energy_oil_forecastingonly.The new shape
Notebook §1 becomes a readable toolbelt — comment a line to drop a tool, uncomment to add:
How it works
The three capabilities land in three different
AgentConfigfields (search sub-agent, code sandbox, function tool). A smallToolSpecdescriptor is the seam: each factory returns one, carrying the config fragment it fills, its playbook skill, any prompt supplement, and a token-budget floor.build_starter_agent_configfolds aSequence[ToolSpec]onto the config and routes each fragment — so the notebook never touches ADK plumbing.starter_agent/tools.py—ToolSpec+news_search(),code_sandbox(),arima_forecast().build_starter_agent_config— booleans →tools=[...]fold.arima_forecast()takesdata_service/series_id/frequency, so it generalizes past WTI (and constructs offline for tests).ToolSpecfactory (was: a cold reference toanalyst_agent.build_wti_tool_config).Testing
test_starter_agent.py(6 tests): each factory routes to exactly one field, composition populates all fields, routing is order-independent.make lint(full pre-commit CI mirror: ruff, ruff-format, mypy, nbqa): clean.root_agent(adk web) path.🤖 Generated with Claude Code