Skip to content

Conversation

@rayruizhiliao
Copy link
Contributor

@rayruizhiliao rayruizhiliao commented Jan 30, 2026

Files Created/Modified

File Action Description
bluebox/data_models/routine_discovery/state.py Created DiscoveryPhase enum and RoutineDiscoveryState class for BFS queue management
bluebox/llms/tools/routine_discovery_tools.py Created 11 tool definitions with JSON schemas
bluebox/agents/routine_discovery_agent.py Rewritten Agentic loop replacing hardcoded pipeline

Architecture Changes

Before: Hardcoded sequential pipeline

run() → identify_transaction() → confirm_identified_transaction()
    → extract_variables() → resolve_variables() → construct_routine()
    → productionize_routine()

After: LLM-driven loop with tools

run() → _run_agent_loop():
    while phase != COMPLETE:
        response = llm_client.call_sync(messages, tools)
            for tool_call in response.tool_calls:
                result = _execute_tool(tool_call)

Tools Available to the LLM

Category Tools
Data Access list_transactions, get_transaction, scan_for_value
Queue Management add_transaction_to_queue, get_queue_status, mark_transaction_complete
State Recording record_identified_transaction, record_extracted_variables, record_resolved_variable
Construction construct_routine, finalize_routine

Key Design Decisions

  1. BFS via tools: The transaction queue is managed through add_transaction_to_queue and mark_transaction_complete - when a variable's source is another transaction, it's auto-added to the queue
  2. Phase-based guidance: System prompt updates with current phase and queue status to guide the LLM
  3. Same interface: The run() method signature and return type are preserved for compatibility
  4. State persistence: RoutineDiscoveryState tracks all intermediate data for routine construction

Test Plan

  • Run existing routine discovery tests
  • Verify BFS dependency resolution with multi-transaction routines
  • Compare output Routine structure with original pipeline

@rayruizhiliao rayruizhiliao changed the title feat: agentic loop for routine discovery Refactored RoutineDiscoveryAgent from a hardcoded sequential pipeline to an LLM-driven agentic loop with tools Jan 30, 2026
@rayruizhiliao rayruizhiliao changed the base branch from network-spy to main January 30, 2026 22:58
@dimavrem22
Copy link
Contributor

dimavrem22 commented Jan 30, 2026

Few thoughts:

I would probably yank these for now then add back in when agent works: record_identified_transaction, record_extracted_variables, record_resolved_variable

--

Edited at 6:24p, 1/30

Dima: Potentially remove queue management tools and manually write them into the agent run flow? Alternatively be very specific about the queue conditions when the agent can exit the loop

@dimavrem22
Copy link
Contributor

could likely consolidate these construct_routine, finalize_routine since agent has access to docs and will get access to execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants