Message Generation#

Message generation capabilities for responding to user queries and requesting clarification when needed.

Respond Capability#

class framework.infrastructure.respond_node.RespondCapability[source]#

Bases: BaseCapability

Respond to user queries with appropriate response strategy.

Generates comprehensive responses for both technical queries requiring execution context and conversational queries. Adapts response strategy based on available context and execution history.

Initialize the capability and validate required components.

Performs comprehensive validation of the capability class to ensure all required components are properly defined. This validation happens at initialization time to provide immediate feedback during development rather than waiting for runtime execution failures.

The validation process checks: 1. Required class attributes (name, description) are defined and non-None 2. The execute method is implemented as a static method 3. Optional attributes are properly initialized with defaults if missing

Raises:
  • NotImplementedError – If name or description class attributes are missing

  • NotImplementedError – If execute static method is not implemented

Note

This initialization performs validation only. The actual LangGraph integration happens through the @capability_node decorator.

Warning

Subclasses should not override this method unless they need additional validation. Override _create_orchestrator_guide() or _create_classifier_guide() for customization instead.

name: str = 'respond'#
description: str = 'Respond to user queries by generating appropriate responses for both technical and conversational questions'#
provides: List[str] = ['FINAL_RESPONSE']#
requires: List[str] = []#
async static execute(state, **kwargs)[source]#

Generate appropriate response using unified dynamic prompt construction.

Parameters:
  • state (AgentState) – Current agent state

  • kwargs – Additional parameters (may include step)

Returns:

State update with generated response

Return type:

Dict[str, Any]

static classify_error(exc, context)[source]#

Response generation error classification.

__init__()#

Initialize the capability and validate required components.

Performs comprehensive validation of the capability class to ensure all required components are properly defined. This validation happens at initialization time to provide immediate feedback during development rather than waiting for runtime execution failures.

The validation process checks: 1. Required class attributes (name, description) are defined and non-None 2. The execute method is implemented as a static method 3. Optional attributes are properly initialized with defaults if missing

Raises:
  • NotImplementedError – If name or description class attributes are missing

  • NotImplementedError – If execute static method is not implemented

Note

This initialization performs validation only. The actual LangGraph integration happens through the @capability_node decorator.

Warning

Subclasses should not override this method unless they need additional validation. Override _create_orchestrator_guide() or _create_classifier_guide() for customization instead.

__repr__()#

Return a string representation of the capability.

Returns:

String representation including class name and capability name

Return type:

str

property classifier_guide: Any | None#

Get the classifier guide for this capability (lazy-loaded).

Standardized interface used by the framework. Automatically calls _create_classifier_guide() on first access and caches the result.

Returns:

Classifier guide for capability activation, or None if not needed

Return type:

Optional[TaskClassifierGuide]

static get_retry_policy()#

Get retry policy configuration for failure recovery strategies.

This method provides retry configuration that the framework uses for manual retry handling when capabilities fail with RETRIABLE errors. The default policy provides reasonable defaults for most capabilities, but should be overridden for capabilities with specific timing or retry requirements.

The retry policy controls: - Maximum number of retry attempts before giving up - Initial delay between retry attempts - Backoff factor for exponential delay increase

Returns:

Dictionary containing retry configuration parameters

Return type:

Dict[str, Any]

Note

The framework uses manual retry handling rather than LangGraph’s native retry policies to ensure consistent behavior across all components and to enable sophisticated error classification.

Examples

Aggressive retry for network-dependent capability:

@staticmethod
def get_retry_policy() -> Dict[str, Any]:
    return {
        "max_attempts": 5,      # More attempts for network issues
        "delay_seconds": 2.0,   # Longer delay for external services
        "backoff_factor": 2.0   # Exponential backoff
    }

Conservative retry for expensive operations:

@staticmethod
def get_retry_policy() -> Dict[str, Any]:
    return {
        "max_attempts": 2,      # Minimal retries for expensive ops
        "delay_seconds": 0.1,   # Quick retry for transient issues
        "backoff_factor": 1.0   # No backoff for fast operations
    }

See also

classify_error() : Error classification that determines when to retry ErrorSeverity : RETRIABLE severity triggers retry policy usage

async langgraph_node(**kwargs)#

LangGraph-native node function with manual retry handling via router.

Return type:

Dict[str, Any]

property orchestrator_guide: Any | None#

Get the orchestrator guide for this capability (lazy-loaded).

Standardized interface used by the framework. Automatically calls _create_orchestrator_guide() on first access and caches the result.

Returns:

Orchestrator guide for execution planning integration, or None if not needed

Return type:

Optional[OrchestratorGuide]

class framework.infrastructure.respond_node.ResponseContext(current_task, execution_history, relevant_context, is_killed, kill_reason, capabilities_overview, total_steps_executed, execution_start_time, reclassification_count, current_date)[source]#

Bases: object

Container for all information needed for response generation.

Aggregates all relevant information from the agent state for comprehensive response generation.

Parameters:
  • current_task (str) – The current task being addressed

  • execution_history (List[Any]) – List of executed steps

  • relevant_context (Dict[str, Any]) – Context data relevant to the response

  • is_killed (bool) – Whether execution was terminated

  • kill_reason (Optional[str]) – Reason for termination if applicable

  • capabilities_overview (Optional[str]) – Overview of available capabilities

  • total_steps_executed (int) – Total number of steps executed

  • execution_start_time (Optional[float]) – When execution started

  • reclassification_count (int) – Number of reclassification attempts

  • current_date (str) – Current date for temporal context

current_task: str#
execution_history: List[Any]#
relevant_context: Dict[str, Any]#
is_killed: bool#
kill_reason: str | None#
capabilities_overview: str | None#
total_steps_executed: int#
execution_start_time: float | None#
reclassification_count: int#
current_date: str#
__init__(current_task, execution_history, relevant_context, is_killed, kill_reason, capabilities_overview, total_steps_executed, execution_start_time, reclassification_count, current_date)#

Clarify Capability#

class framework.infrastructure.clarify_node.ClarifyCapability[source]#

Bases: BaseCapability

Ask user for clarification when queries are ambiguous.

Communication capability that generates targeted questions to clarify user intent when requests lack sufficient detail or context.

Initialize the capability and validate required components.

Performs comprehensive validation of the capability class to ensure all required components are properly defined. This validation happens at initialization time to provide immediate feedback during development rather than waiting for runtime execution failures.

The validation process checks: 1. Required class attributes (name, description) are defined and non-None 2. The execute method is implemented as a static method 3. Optional attributes are properly initialized with defaults if missing

Raises:
  • NotImplementedError – If name or description class attributes are missing

  • NotImplementedError – If execute static method is not implemented

Note

This initialization performs validation only. The actual LangGraph integration happens through the @capability_node decorator.

Warning

Subclasses should not override this method unless they need additional validation. Override _create_orchestrator_guide() or _create_classifier_guide() for customization instead.

name: str = 'clarify'#
description: str = 'Ask specific questions when user queries are ambiguous or missing critical details'#
provides: List[str] = []#
requires: List[str] = []#
async static execute(state, **kwargs)[source]#

Generate specific questions to ask user based on missing information.

Parameters:
  • state (AgentState) – Current agent state

  • kwargs – Additional parameters (may include step)

Returns:

State update with clarification response

Return type:

Dict[str, Any]

static classify_error(exc, context)[source]#

Clarify error classification.

__init__()#

Initialize the capability and validate required components.

Performs comprehensive validation of the capability class to ensure all required components are properly defined. This validation happens at initialization time to provide immediate feedback during development rather than waiting for runtime execution failures.

The validation process checks: 1. Required class attributes (name, description) are defined and non-None 2. The execute method is implemented as a static method 3. Optional attributes are properly initialized with defaults if missing

Raises:
  • NotImplementedError – If name or description class attributes are missing

  • NotImplementedError – If execute static method is not implemented

Note

This initialization performs validation only. The actual LangGraph integration happens through the @capability_node decorator.

Warning

Subclasses should not override this method unless they need additional validation. Override _create_orchestrator_guide() or _create_classifier_guide() for customization instead.

__repr__()#

Return a string representation of the capability.

Returns:

String representation including class name and capability name

Return type:

str

property classifier_guide: Any | None#

Get the classifier guide for this capability (lazy-loaded).

Standardized interface used by the framework. Automatically calls _create_classifier_guide() on first access and caches the result.

Returns:

Classifier guide for capability activation, or None if not needed

Return type:

Optional[TaskClassifierGuide]

static get_retry_policy()#

Get retry policy configuration for failure recovery strategies.

This method provides retry configuration that the framework uses for manual retry handling when capabilities fail with RETRIABLE errors. The default policy provides reasonable defaults for most capabilities, but should be overridden for capabilities with specific timing or retry requirements.

The retry policy controls: - Maximum number of retry attempts before giving up - Initial delay between retry attempts - Backoff factor for exponential delay increase

Returns:

Dictionary containing retry configuration parameters

Return type:

Dict[str, Any]

Note

The framework uses manual retry handling rather than LangGraph’s native retry policies to ensure consistent behavior across all components and to enable sophisticated error classification.

Examples

Aggressive retry for network-dependent capability:

@staticmethod
def get_retry_policy() -> Dict[str, Any]:
    return {
        "max_attempts": 5,      # More attempts for network issues
        "delay_seconds": 2.0,   # Longer delay for external services
        "backoff_factor": 2.0   # Exponential backoff
    }

Conservative retry for expensive operations:

@staticmethod
def get_retry_policy() -> Dict[str, Any]:
    return {
        "max_attempts": 2,      # Minimal retries for expensive ops
        "delay_seconds": 0.1,   # Quick retry for transient issues
        "backoff_factor": 1.0   # No backoff for fast operations
    }

See also

classify_error() : Error classification that determines when to retry ErrorSeverity : RETRIABLE severity triggers retry policy usage

async langgraph_node(**kwargs)#

LangGraph-native node function with manual retry handling via router.

Return type:

Dict[str, Any]

property orchestrator_guide: Any | None#

Get the orchestrator guide for this capability (lazy-loaded).

Standardized interface used by the framework. Automatically calls _create_orchestrator_guide() on first access and caches the result.

Returns:

Orchestrator guide for execution planning integration, or None if not needed

Return type:

Optional[OrchestratorGuide]

Core Models#

Message generation uses models defined in the core framework:

See also

BaseCapability

Base class for all capabilities

ContextManager

Context management for response generation

Registration#

Respond Capability is automatically registered as:

CapabilityRegistration(
    name="respond",
    module_path="framework.infrastructure.respond_node",
    class_name="RespondCapability",
    provides=["FINAL_RESPONSE"]
)

Clarify Capability is automatically registered as:

CapabilityRegistration(
    name="clarify",
    module_path="framework.infrastructure.clarify_node",
    class_name="ClarifyCapability",
    provides=[]
)

See also

Prompt System

Prompt customization system

Registry System

Component registration system

Message Generation

Implementation details and usage patterns