kodeagent.kodeagent.Agent#

class kodeagent.kodeagent.Agent(model_name: str, *, name: str | None = None, description: str | None = None, tools: list[~collections.abc.Callable] = <factory>, litellm_params: dict = <factory>, persona: str | None = None, system_prompt: str | None = None, max_iterations: int = 20, filter_tools_for_task: bool = False, max_retries: int = 3, work_dir: str | None = None, tracing_type: ~typing.Literal['langfuse', 'langsmith'] | None = None)[source]#

An abstract agent. Base class for all types of agents.

__init__(model_name: str, *, name: str | None = None, description: str | None = None, tools: list[~collections.abc.Callable] = <factory>, litellm_params: dict = <factory>, persona: str | None = None, system_prompt: str | None = None, max_iterations: int = 20, filter_tools_for_task: bool = False, max_retries: int = 3, work_dir: str | None = None, tracing_type: ~typing.Literal['langfuse', 'langsmith'] | None = None) None#

Methods

__init__(model_name, *[, name, description, ...])

add_output_file(path)

Record a file generated during task execution.

add_to_history(message)

Add a chat message to the agent's message history.

clear_history()

Clear the agent's message history.

get_history()

Get a formatted string of the agent's message history, excluding the system prompt

get_system_prompt_content()

Return the formatted system prompt string for this agent.

get_tools_description([tools])

Generate a description of all the tools available to the agent.

get_usage_metrics()

Get raw usage metrics as a dictionary.

get_usage_report([include_breakdown])

Get a formatted report of LLM usage for the current/last task.

init_history()

Initialize the agent's message history, e.g., with a system prompt.

normalize_content(content)

Convert message content to a readable string for Observer.

parse_text_response(text)

Parse a text response from the LLM into a ChatMessage.

post_run()

Hook intended to run after the main agent loop.

pre_run()

Hook intended to run before the main agent loop.

response(rtype, value[, channel, metadata])

Prepare a response to be sent by the agent.

run(task[, files, task_id, max_iterations, ...])

Execute a task using the agent.

salvage_response()

When an agent fails to find an answer, salvage what information could be gathered.

Attributes