This commit is contained in:
AI Christianson 2024-12-28 15:18:58 -05:00
parent 5c5df65694
commit 2af7f8a623
3 changed files with 32 additions and 0 deletions

View File

@ -422,6 +422,8 @@ def run_task_implementation_agent(
try: try:
logger.debug("Implementation agent completed successfully") logger.debug("Implementation agent completed successfully")
return run_agent_with_retry(agent, prompt, run_config) return run_agent_with_retry(agent, prompt, run_config)
except (KeyboardInterrupt, AgentInterrupt):
raise
except Exception as e: except Exception as e:
logger.error("Implementation agent failed: %s", str(e), exc_info=True) logger.error("Implementation agent failed: %s", str(e), exc_info=True)
raise raise

View File

View File

@ -4,6 +4,36 @@ from langchain_core.messages import AIMessage, HumanMessage, BaseMessage
from ra_aid.exceptions import ToolExecutionError from ra_aid.exceptions import ToolExecutionError
class CiaynAgent: class CiaynAgent:
"""Code Is All You Need (CIAYN) agent that uses generated Python code for tool interaction.
The CIAYN philosophy emphasizes direct code generation and execution over structured APIs:
- Language model generates executable Python code snippets
- Tools are invoked through natural Python code rather than fixed schemas
- Flexible and adaptable approach to tool usage through dynamic code
- Complex workflows emerge from composing code segments
Code Generation & Function Calling:
- Dynamic generation of Python code for tool invocation
- Handles complex nested function calls and argument structures
- Natural integration of tool outputs into Python data flow
- Runtime code composition for multi-step operations
ReAct Pattern Implementation:
- Observation: Captures tool execution results
- Reasoning: Analyzes outputs to determine next steps
- Action: Generates and executes appropriate code
- Reflection: Updates state and plans next iteration
- Maintains conversation context across iterations
Core Capabilities:
- Dynamic tool registration with automatic documentation
- Sandboxed code execution environment
- Token-aware chat history management
- Comprehensive error handling and recovery
- Streaming interface for real-time interaction
- Memory management with configurable limits
"""
def _get_function_info(self, func): def _get_function_info(self, func):
""" """
Returns a well-formatted string containing the function signature and docstring, Returns a well-formatted string containing the function signature and docstring,