kodeagent.orchestrator.Observer#

class kodeagent.orchestrator.Observer(model_name: str, tool_names: set[str], litellm_params: dict | None = None, threshold: int | None = 3, max_retries: int = 3, usage_tracker: UsageTracker | None = None, tracer_manager: AbstractTracerManager | None = None)[source]#

Monitors an agent’s behavior to detect issues like loops or stalled plans.

Create an Observer for an agent.

Parameters:
  • model_name – The LLM to use.

  • tool_names – The set of tools available to the agent.

  • litellm_params – LiteLLM parameters.

  • threshold – Observation threshold, i.e., how frequently the observer will analyze the chat history.

  • max_retries – Maximum number of retries for LLM calls.

  • usage_tracker – Optional UsageTracker instance to record usage.

  • tracer_manager – Optional AbstractTracerManager for hierarchical tracing.

__init__(model_name: str, tool_names: set[str], litellm_params: dict | None = None, threshold: int | None = 3, max_retries: int = 3, usage_tracker: UsageTracker | None = None, tracer_manager: AbstractTracerManager | None = None)[source]#

Create an Observer for an agent.

Parameters:
  • model_name – The LLM to use.

  • tool_names – The set of tools available to the agent.

  • litellm_params – LiteLLM parameters.

  • threshold – Observation threshold, i.e., how frequently the observer will analyze the chat history.

  • max_retries – Maximum number of retries for LLM calls.

  • usage_tracker – Optional UsageTracker instance to record usage.

  • tracer_manager – Optional AbstractTracerManager for hierarchical tracing.

Methods

__init__(model_name, tool_names[, ...])

Create an Observer for an agent.

observe(iteration, task, history, ...[, ...])

Observe the agent's state and return a corrective message if a problem is detected.

reset()

Reset the observer state.