Files
deepseek-harness/scripts/fixtures/python-sdk-dynamic-tools.mjs
T
Yichen Jiang 06d1caf82f feat(agent): choose the step route through agent/route
- Add the agent/route waterfall, dispatched once per proposed step before
  system-prompt/prepare and agent/pre-step; model selection captures its
  choice there, and a later selection applies from the next step.
- Pass the chosen StepRoute to prompt preparation and assembly, the
  agent/pre-step payload, and tool conditions; remove Agent.currentRoute().
- Run agent/request and prepareCall() for each attempt after step/start and
  prompt assembly; agent/request may change only call controls, and another
  provider or model fails the step.
- Resolve conditional tools and assemble the prompt once per step; retries
  reuse the route, tool set, and rendered assembly.
- Update documentation, Agent Notes, generated catalogs, tests, and the
  cordis-inspect-jsdoc snapshot.
2026-10-12 23:59:29 +08:00

29 lines
1.1 KiB
JavaScript

/** Activate a native tool after a file read and disable it after its first execution. */
export const name = 'python-sdk-dynamic-tools'
export const inject = ['tools']
/** @param {import('@deepseek-ai/cordis').Context} ctx - Scenario-owned tool registry. */
export function apply(ctx) {
let active = false
ctx.tools.register({
name: 'snapshot_ping',
description: 'Return pong once.',
parameters: { type: 'object', properties: {}, additionalProperties: false },
output: {
schema: { type: 'string' },
render(_args, value) { return [{ type: 'text', text: value }] },
},
async execute() { return 'pong' },
}, { when: async ({ route }) => active && route.provider === 'deepseek-official' })
ctx.on('tools/post-execute', async (exec, result, next) => {
const downstream = await next()
if (result.isError) return downstream
if (exec.name === 'read' && exec.arguments.file_path === 'dynamic-tool-task.txt') {
active = true
} else if (exec.name === 'snapshot_ping') {
active = false
}
return downstream
})
}