feat(agent-core): add config hint to max-steps-per-turn error (#1097)

* feat(agent-core): add config hint to max-steps-per-turn error

* test(agent-core): assert config hint in max-steps error
This commit is contained in:
liruifengv 2026-06-25 15:49:44 +08:00 committed by GitHub
parent 0030f76c5c
commit 27ef516695
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 4 deletions

View file

@ -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.

View file

@ -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',

View file

@ -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 {

View file

@ -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,
}),