Reasoning

ReasoningTools provides step-by-step reasoning capabilities for agents to think through complex problems systematically.

Example

The following agent can use structured reasoning to solve complex problems:

1from kern.agent import Agent
2from kern.tools.reasoning import ReasoningTools
3
4agent = Agent(
5 instructions=[
6 "You are a logical reasoning assistant that breaks down complex problems",
7 "Use step-by-step thinking to analyze situations thoroughly",
8 "Apply structured reasoning to reach well-founded conclusions",
9 "Show your reasoning process clearly to help users understand your logic",
10 ],
11 tools=[ReasoningTools()],
12)
13
14agent.print_response("Analyze the pros and cons of remote work for software developers", stream=True)

Toolkit Params

ParameterTypeDefaultDescription
enable_thinkboolTrueEnable the think reasoning function.
enable_analyzeboolTrueEnable the analyze reasoning function.
instructionsOptional[str]NoneCustom instructions for reasoning behavior.
add_instructionsboolFalseWhether to add instructions to the agent.
add_few_shotboolFalseWhether to include few-shot examples.
few_shot_examplesOptional[str]NoneCustom few-shot examples for reasoning.

Toolkit Functions

FunctionDescription
thinkPerform step-by-step reasoning about a problem or situation.
analyzeConduct detailed analysis with structured reasoning steps.

Developer Resources