-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy path50-thinking-config.ts
More file actions
77 lines (68 loc) · 2.35 KB
/
Copy path50-thinking-config.ts
File metadata and controls
77 lines (68 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* 50 - Thinking Config — enable extended reasoning for complex tasks.
*
* When `thinkingBudgetTokens` is set, the agent uses extended thinking
* mode, allowing the LLM to reason step-by-step before responding.
*
* Requirements:
* - Conductor server with thinking config support
* - CONDUCTOR_SERVER_URL=http://localhost:8080/api
* - CONDUCTOR_AGENT_LLM_MODEL=openai/gpt-4o-mini
*/
import { Agent, AgentRuntime, tool } from '@io-orkes/conductor-javascript/agents';
import { llmModel } from './settings';
// -- Tool --------------------------------------------------------------------
const calculate = tool(
async (args: { expression: string }) => {
try {
const fn = new Function(`return (${args.expression});`);
return { expression: args.expression, result: fn() };
} catch (e) {
return { expression: args.expression, error: String(e) };
}
},
{
name: 'calculate',
description: 'Evaluate a mathematical expression.',
inputSchema: {
type: 'object',
properties: {
expression: { type: 'string', description: 'A math expression to evaluate (e.g., \'2 + 3 * 4\')' },
},
required: ['expression'],
},
},
);
// -- Agent -------------------------------------------------------------------
export const agent = new Agent({
name: 'deep_thinker_50',
model: llmModel,
instructions:
'You are an analytical assistant. Think carefully through complex ' +
'problems step by step. Use the calculate tool for math.',
tools: [calculate],
thinkingBudgetTokens: 2048,
});
// -- Run ---------------------------------------------------------------------
async function main() {
const runtime = new AgentRuntime();
try {
const result = await runtime.run(
agent,
'If a train travels 120 km in 2 hours, then speeds up by 50% for ' +
'the next 3 hours, what is the total distance traveled?',
);
result.printResult();
// Production pattern:
// 1. Deploy once during CI/CD (optional -- serve() below also deploys):
// await runtime.deploy(agent);
// CLI alternative:
// conductor deploy --package examples/agents --agents deep_thinker_50
//
// 2. In a separate long-lived worker process (deploys + registers workers + starts polling):
// await runtime.serve(agent);
} finally {
await runtime.shutdown();
}
}
main().catch(console.error);