Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/max-steps-config-hint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

Add a hint to the per-turn step limit error pointing users to the loop_control.max_steps_per_turn config option.
2 changes: 1 addition & 1 deletion packages/agent-core/src/errors/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export const KIMI_ERROR_INFO = {
title: 'Turn exceeded max steps',
retryable: false,
public: true,
action: 'Increase loop_control.max_steps_per_turn or split the task.',
action: 'Increase loop_control.max_steps_per_turn in config.toml or split the task.',
},
'provider.api_error': {
title: 'Provider API error',
Expand Down
11 changes: 8 additions & 3 deletions packages/agent-core/src/loop/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
import { ErrorCodes, KimiError, isKimiError } from '#/errors';

export function createMaxStepsExceededError(maxSteps: number, message?: string): KimiError {
return new KimiError(ErrorCodes.LOOP_MAX_STEPS_EXCEEDED, message ?? `Turn exceeded maxSteps=${maxSteps}`, {
details: { maxSteps },
});
return new KimiError(
ErrorCodes.LOOP_MAX_STEPS_EXCEEDED,
message ??
`Turn exceeded maxSteps=${maxSteps}. If max_steps_per_turn is too small, raise it in config.toml (loop_control.max_steps_per_turn).`,
{
details: { maxSteps },
},
);
}

export function isMaxStepsExceededError(error: unknown): boolean {
Expand Down
1 change: 1 addition & 0 deletions packages/agent-core/test/agent/turn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,7 @@ describe('Agent turn flow', () => {
reason: 'failed',
error: expect.objectContaining({
code: 'loop.max_steps_exceeded',
message: expect.stringContaining('config.toml'),
details: expect.objectContaining({
maxSteps: 1,
}),
Expand Down
Loading