fix: abort signal in polling loops, remove legacy k2p5, pass ctx.directory to skill tool
- Check context.abort in background-wait and background-output polling loops - Remove legacy kimi-for-coding/k2p5 from athena fallback chain - Pass ctx.directory from tool-registry to createSkillTool instead of process.cwd()
This commit is contained in:
@@ -183,7 +183,6 @@ export const AGENT_MODEL_REQUIREMENTS: Record<string, ModelRequirement> = {
|
||||
athena: {
|
||||
fallbackChain: [
|
||||
{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-opus-4-6", variant: "max" },
|
||||
{ providers: ["kimi-for-coding"], model: "k2p5" },
|
||||
{ providers: ["opencode"], model: "kimi-k2.5-free" },
|
||||
{ providers: ["zai-coding-plan"], model: "glm-4.7" },
|
||||
{ providers: ["opencode"], model: "glm-4.7-free" },
|
||||
|
||||
@@ -95,8 +95,13 @@ export function createBackgroundOutput(manager: BackgroundOutputManager, client:
|
||||
let didTimeoutWhileActive = false
|
||||
|
||||
if (shouldBlock && isTaskActiveStatus(task.status)) {
|
||||
const abort = (toolContext as { abort?: AbortSignal } | undefined)?.abort
|
||||
const startTime = Date.now()
|
||||
while (Date.now() - startTime < timeoutMs) {
|
||||
if (abort?.aborted) {
|
||||
return formatTaskStatus(task)
|
||||
}
|
||||
|
||||
await delay(1000)
|
||||
|
||||
const currentTask = manager.getTask(args.task_id)
|
||||
|
||||
@@ -21,7 +21,9 @@ export function createBackgroundWait(manager: BackgroundOutputManager, client: B
|
||||
task_ids: tool.schema.array(tool.schema.string()).describe("Task IDs to monitor — returns when ANY one reaches a terminal state"),
|
||||
timeout: tool.schema.number().optional().describe("Max wait in ms. Default: 120000 (2 min). The tool returns immediately when any task finishes, so large values are fine."),
|
||||
},
|
||||
async execute(args: { task_ids: string[]; timeout?: number }) {
|
||||
async execute(args: { task_ids: string[]; timeout?: number }, toolContext?: unknown) {
|
||||
const abort = (toolContext as { abort?: AbortSignal } | undefined)?.abort
|
||||
|
||||
const taskIds = args.task_ids
|
||||
if (!taskIds || taskIds.length === 0) {
|
||||
return "Error: task_ids array is required and must not be empty."
|
||||
@@ -36,6 +38,10 @@ export function createBackgroundWait(manager: BackgroundOutputManager, client: B
|
||||
|
||||
const startTime = Date.now()
|
||||
while (Date.now() - startTime < timeoutMs) {
|
||||
if (abort?.aborted) {
|
||||
return buildProgressSummary(manager, taskIds, true)
|
||||
}
|
||||
|
||||
await delay(1000)
|
||||
|
||||
const found = findFirstTerminal(manager, taskIds)
|
||||
|
||||
@@ -138,7 +138,7 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
|
||||
body = injectGitMasterConfig(body, options.gitMasterConfig)
|
||||
}
|
||||
|
||||
const dir = matchedSkill.path ? dirname(matchedSkill.path) : matchedSkill.resolvedPath || process.cwd()
|
||||
const dir = matchedSkill.path ? dirname(matchedSkill.path) : matchedSkill.resolvedPath || options.directory || process.cwd()
|
||||
|
||||
const output = [
|
||||
`## Skill: ${matchedSkill.name}`,
|
||||
|
||||
Reference in New Issue
Block a user