Branching

Test alternative prompts or tools side-by-side. Create new execution branches from any step.

Git for Agents

Just like Git lets you create branches to test code changes, Sentrial lets you create branches to test agent behavior changes. Fork from any point, try different approaches, and merge what works.

Why Branching?

๐Ÿงช A/B Test Prompts

Found a step where your agent struggles? Branch from that point and try a different prompt to see if it performs better.

๐Ÿ”ง Test Tool Changes

Replace a tool with an alternative and compare performance side-by-side without affecting production.

๐Ÿ” Explore "What If?"

What if your agent chose differently at step 15? Branch and see where that path leads.

How Branching Works

Visual Example

StartBranch PointBranch A (new)Branch B (original)

Step-by-Step

  1. 1
    Select a branch point - Choose any event in the timeline
  2. 2
    Create branch - Fork the execution from that point
  3. 3
    Make changes - Modify prompts, tools, or parameters
  4. 4
    Run & compare - Execute the new branch and compare results

Creating Branches (Dashboard)

The easiest way to create branches is through the web dashboard:

  1. Open a session - Navigate to any completed session in your dashboard
  2. Find the branch point - Scrub through the timeline to find where you want to branch
  3. Click "Create Branch" - Button appears when hovering over events
  4. Modify & run - Make your changes in the branch editor and execute

Creating Branches (API)

For programmatic branching, use the SDK:

from sentrial import SentrialClient

client = SentrialClient(api_key="...", project_id="...")

# Create a branch from a specific event
branch_session_id = client.create_branch(
    parent_session_id="session_123",
    branch_from_event_index=12,  # Branch from step 12
    name="Test Alternative Prompt",
    modifications={
        "prompt": "New improved prompt...",
        "temperature": 0.7
    }
)

# Continue execution from the branch point
# with your modifications
client.track_tool_call(
    session_id=branch_session_id,
    tool_name="search_kb",
    ...
)

# Compare results
original = client.get_session("session_123")
branched = client.get_session(branch_session_id)

print(f"Original success rate: {original['success_rate']}")
print(f"Branch success rate: {branched['success_rate']}")

Use Cases

Prompt Engineering

Your agent struggles with a specific type of question. Branch from where it fails and test different prompts until you find one that works.

Example: Agent can't handle ambiguous questions. Create 3 branches with different clarification prompts and compare which performs best.

Tool Optimization

Compare different tool implementations or APIs side-by-side.

Example: You have 2 search APIs. Branch and test both to see which returns better results for your use case.

Safety Testing

Test edge cases and failure modes without running full production flows.

Example: Simulate API failures at different points to ensure your agent handles errors gracefully.

Merging Branches

Once you've validated that a branch performs better, you can merge it:

Safe Merges

Sentrial analyzes both branches and helps you merge changes safely, ensuring improvements don't break existing functionality.

  • Automatic conflict detection
  • Performance comparison metrics
  • Rollback if issues detected
# Compare branch performance
comparison = client.compare_sessions(
    session_id_a="original_session",
    session_id_b="branch_session"
)

# If branch is better, merge it
if comparison["branch_b_better"]:
    client.merge_branch(
        target="production",
        branch_session_id="branch_session",
        auto_rollback=True  # Rollback if issues detected
    )

Coming Soon

Full branching and merging features are currently in beta. Advanced merge strategies and automated testing will be available soon.