Programmatic agent creation silently no-ops: prompt variable "{{model}}" has no value, loop swallows the error (dsh 0.1.1-rc.2) #4967
Replies: 2 comments
|
Confirmed source-verified against the current tip The decisive precedent is if (model === undefined) {
const selected = ctx.agentDefaultModel.currentSelection()
agentOptions = { provider: selected.provider, model: selected.model }
modelSelection = { ...selected }
}So Side 1 — the ctx.systemPrompt.variable('model', context => context.agent?.options.model)
Side 2 — the render error masks the real route error, and try {
while (await this.turn()) {}
} catch (_error) {
// Reported failures and cancellation are contained at the driver boundary.
}and The fix has a clean precedent to follow. Mirror the webhook fallback in the agent-loop entry: when building the I'd be glad to help with a fork branch + tests if you want to take the webhook-fallback approach — it's a small, well-scoped change with an in-tree precedent to test against. Happy to hold for your call on the preferred fix shape. 中文摘要:已在 alpha.1 源码确认你的两缺陷诊断精确,并指出这是有既有先例但 agent-loop 未遵循的已知模式—— |
|
Confirmed on master (c291e79). Both defects in your report are still present, and the in-tree precedent argument
Workaround today (works, no fork needed): don't omit the model — resolve it yourself before create and pass it: const selected = ctx.agentDefaultModel.currentSelection()
await ctx.agents.create({ ..., agentOptions: { provider: selected.provider, model: selected.model } })and/or check Fix direction for upstream: mirror the webhook fallback in the agent-loop entry (bind the |
Uh oh!
There was an error while loading. Please reload this page.
Bug Description
Creating an agent programmatically (
ctx.agents.create({agentOptions: {provider: "deepseek-official"}, ...})thenagent.followup(userMsg)+await agent.whenIdle()) silently produces a dead turn: the LLM is never called, stats are all zero, and the caller cannot distinguish "task done" from "task crashed". Two defects compound:Prompt rendering fails without an explicit model - the host persona requires
{{model}}(sectiondeployment:persona), and the variable is bound tocontext.agent?.options.model(dsh-agent-loop/lib/index.js:1024-1026) with no fallback toagentDefaultModel. Programmatic callers that omitmodelin agentOptions (as our MCP bridge did, since the default is"") hitprompt variable "{{model}}" has no value for this assembly (section "deployment:persona")at the firstrenderPrompt(dsh-agent-loop/lib/index.js:611).The loop swallows the error -
kick()wraps turns intry { while (await this.turn()); } catch (_error) {}(dsh-agent-loop/lib/index.js:477-491), andwhenIdle()resolves normally after an error turn (:460-465). The failure is only visible deep in the session log (turn/endwithreason.kind === "error").Steps to Reproduce
modelin agentOptions:All reactions