Turn strava.py chat into a tool-using agent with runlog search#3
Open
sahilds1 wants to merge 1 commit into
Open
Turn strava.py chat into a tool-using agent with runlog search#3sahilds1 wants to merge 1 commit into
sahilds1 wants to merge 1 commit into
Conversation
Replace the passive single-shot chat with an agent loop: the conversation now runs llm's tool-calling loop (model.conversation(tools=[...]) + conversation.chain()), so the model can decide mid-conversation to call a tool and act on the result, instead of only answering from the seeded activity JSON. The agent's first tool is search_runlog, a keyword search over the athlete's running log (RUNLOG.txt, override with --runlog). It lives in a new self-contained strava_tools.py built from pure parse_runlog / search_entries / format_entries helpers, which are the test targets in test_strava_tools.py. Adding a second tool is a one-line change to the tools=[...] list. format_entries returns self-contained titles + bodies on purpose: with the default OpenAI (Chat Completions) plugin, reasoning state is not preserved across turns or across a tool hop, so the tool's returned text is the only durable state the next turn sees. strava.py carries a comment on this and on the OpenAI Agents SDK as a future extension path. Also updates SYSTEM_PROMPT to tell the model about the tool and to ground history claims in what it returns, and documents the agent in CLAUDE.md.
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.
Replace the passive single-shot chat with an agent loop: the conversation now runs llm's tool-calling loop (model.conversation(tools=[...]) + conversation.chain()), so the model can decide mid-conversation to call a tool and act on the result, instead of only answering from the seeded activity JSON.
The agent's first tool is search_runlog, a keyword search over the athlete's running log (RUNLOG.txt, override with --runlog). It lives in a new self-contained strava_tools.py built from pure parse_runlog / search_entries / format_entries helpers, which are the test targets in test_strava_tools.py. Adding a second tool is a one-line change to the tools=[...] list.
format_entries returns self-contained titles + bodies on purpose: with the default OpenAI (Chat Completions) plugin, reasoning state is not preserved across turns or across a tool hop, so the tool's returned text is the only durable state the next turn sees. strava.py carries a comment on this and on the OpenAI Agents SDK as a future extension path.
Also updates SYSTEM_PROMPT to tell the model about the tool and to ground history claims in what it returns, and documents the agent in CLAUDE.md.