Overview
After building components, you’ll often need to refine them. Triton can help you modify code, update prompts, restructure Flows, and optimize performance through natural conversation.Editing Actions
Code modifications
Simple changes: “Add logging to this Action""Add a timeout parameter"
"Remove the deprecated function"
"Rename the parameter from ‘data’ to ‘input_data’” Refactoring: “Extract the validation logic into a separate function"
"Convert this to async/await"
"Replace the for loop with a list comprehension"
"Add type hints to all functions” Error handling: “Add try-catch for JSON parsing errors"
"Handle the case where the API returns 404"
"Add validation for negative numbers"
"Return a default value if the request fails”
Example: Adding retry logic
You: “Add retry logic to this API call” Triton modifies: Before:requirements.txt
:
Performance optimizations
“Cache the results of this expensive function""Batch the API calls instead of calling one at a time"
"Use a connection pool"
"Add async for I/O operations”
Editing Agents
Prompt refinement
Tone adjustments: “Make this Agent more formal""Make responses more concise"
"Add a friendly, conversational tone"
"Make it sound like a technical expert” Behavior changes: “Always ask for confirmation before taking actions"
"Include sources for all facts mentioned"
"Format responses as markdown"
"Add step-by-step reasoning” Example: Refining a support Agent You: “Make this support Agent more empathetic and proactive” Triton updates system prompt: Before:
Tool management
Adding tools: “Add the search_documentation Action as a tool""Give this Agent access to the billing_update Flow” Removing tools: “Remove the delete_account tool—it’s too risky"
"This Agent shouldn’t have access to user_data anymore” Tool usage guidance: “Update the prompt to encourage using the search tool first"
"Add examples of when to use each tool"
"Clarify that create_ticket should be used only when unable to resolve”
Model and parameter adjustments
“Switch this Agent to Claude instead of GPT-4""Lower the temperature to 0.2 for more consistent output"
"Increase max tokens to 2000 for longer responses"
"Add top_p=0.9 to reduce repetition”
Editing Flows
Structural changes
Adding nodes: “Add a validation Action before processing""Insert a logging step after each Action"
"Add an error handler at the end” Removing nodes: “Remove the deprecated transform_data Action"
"Delete the unused notification step” Reordering: “Swap the order of validation and normalization"
"Move the notification to happen before storage, not after”
Converting serial to parallel
You: “Make this Flow process items in parallel instead of sequentially” Triton restructures: Before:Adding conditional logic
You: “Route premium users to enhanced_process and regular users to standard_process” Triton adds:Error handling in Flows
“Add error routing so failed items go to a retry queue""If validation fails, log the error and continue with the next item"
"Add a fallback path if the primary API is down”
Editing entire Projects
High-level modifications
Feature additions: “Add rate limiting to this Project""Add authentication checks"
"Implement caching throughout"
"Add comprehensive logging” Architectural changes: “Split this monolithic Flow into three smaller sub-Flows"
"Move all validation logic into a dedicated validation Flow"
"Create a shared error handling Flow that all components use” Performance improvements: “Optimize this Project to handle 10x more requests"
"Reduce the number of API calls"
"Add batching to reduce execution time”
Refactoring for reusability
You: “Extract the email sending logic so other Projects can use it” Triton:- Creates a new Action:
send_email
- Extracts the logic from the current Flow
- Replaces inline logic with the new Action
- Updates dependencies
send_email
.
Contextual editing
Triton understands your Project context when editing.Editing multiple related components
You: “Update all Actions to use the new error logging format” Triton:- Scans all Actions in the Project
- Identifies logging statements
- Updates each one consistently
- Reports what was changed
Maintaining consistency
You: “Make this new Action follow the same patterns as my existing ones” Triton:- Reviews your existing Actions
- Matches coding style
- Uses same error handling approach
- Follows same naming conventions
Bulk edits
You: “Add a timeout parameter to all Actions that make API calls” Triton:- Finds all relevant Actions
- Adds
timeout
parameter to each - Updates function signatures
- Sets reasonable defaults
Iterative refinement
Edit through conversation:Iteration example
You: “Create an Action that fetches user data”Triton: [Creates basic Action] You: “Add caching”
Triton: [Adds cache logic] You: “Cache should expire after 5 minutes”
Triton: [Adds TTL] You: “Add logging when cache hits vs misses”
Triton: [Adds logging] You: “Handle the case where the user doesn’t exist”
Triton: [Adds not-found handling] Each iteration builds on the previous changes.
Editing with constraints
Give Triton constraints to guide edits: Performance:- “Optimize this, but keep it under 100ms”
- “Reduce API calls without changing functionality”
- “Update this but maintain backward compatibility”
- “Migrate to the new API while supporting the old one”
- “Refactor this to follow PEP 8”
- “Make this more Pythonic”
- “Add input sanitization but don’t break existing tests”
- “Improve error handling without changing output format”
Reviewing Triton’s edits
Always review changes:- Check the diff — What exactly changed?
- Test the component — Does it still work?
- Verify edge cases — Does it handle errors properly?
- Review new dependencies — Are they necessary and safe?
- “Undo that change”
- “That broke the validation, please fix”
- “Actually, let’s try a different approach”
Best practices for editing
Be specific — “Add error handling” is vague; “Add try-catch for JSON decode errors” is clear
Test after edits — Always run Execute to verify changes work
Edit incrementally — One change at a time is easier to debug
Explain why — “Add caching because this API is rate-limited” gives Triton better context
Review before deploying — Changes look different in production
Common editing scenarios
Scenario: Action is failing in production
Diagnosis: “Execution #1234 failed. What’s wrong?” Triton identifies: Timeout error on API call Fix: “Add retry with exponential backoff and increase timeout to 30s” Triton edits: Adds tenacity retry decorator, increases timeout Verify: Test with Execute, redeployScenario: Agent responses are too verbose
Problem: “This Agent is writing essays instead of concise answers” Fix: “Update the prompt to limit responses to 2-3 sentences” Triton edits: Adds constraint to system prompt Verify: Test with sample inputsScenario: Flow is too slow
Problem: “This Flow takes 30 seconds to process 50 items” Analysis: “Why is it slow?” Triton identifies: Sequential processing of independent items Fix: “Convert to parallel processing” Triton edits: Restructures Flow for parallel execution Result: Processing time drops to ~5 secondsAdvanced editing techniques
Conditional edits
“If the Action uses requests, add retry logic""For all Agents that use tools, add tool usage examples in the prompt”
Pattern-based edits
“Find all places where we call external APIs and add timeout handling""Update all validation Actions to return structured error objects”
Version-based edits
“Create a v2 of this Agent with the improvements, but keep v1 for now""Update all components to use the new API, but create a flag to fall back to the old one”