Skip to content

Malformed KIMI_LOG_* limits are applied by prefix (10MB becomes 10 bytes) #4324

Open

Description

@mertkayacs

What version of Kimi Code is running?

2.3.0. I also reproduced it on main at 874d9ab.

Which open platform/subscription were you using?

Kimi Code subscription. The bug happens while the logging config is read, before any provider or model is used.

Which model were you using?

No response

What platform is your computer?

Linux x86_64

What issue are you seeing?

The numeric KIMI_LOG_* settings are read by their leading digits, so a malformed value is applied instead of ignored. KIMI_LOG_GLOBAL_MAX_BYTES=10MB resolves to 10 bytes, and 1024bytes resolves to 1,024 bytes, instead of the documented 6 MB default. The same parser handles KIMI_LOG_GLOBAL_FILES, KIMI_LOG_SESSION_MAX_BYTES and KIMI_LOG_SESSION_FILES.

What steps can reproduce the bug?

  1. Call resolveLoggingConfig({ homeDir: '/tmp', env: { KIMI_LOG_GLOBAL_MAX_BYTES: '1024bytes' } }).
  2. Read globalMaxBytes from the result.
  3. It is 1024 instead of the default 6291456.

What is the expected behavior?

A malformed value should be ignored so the documented default applies. A complete positive integer should keep working as it does now.

Additional information

parsePositiveInt in packages/agent-core-v2/src/_base/log/logConfig.ts uses Number.parseInt, which accepts a numeric prefix and drops the rest. The result goes straight to the rotating file writers in logService.ts and sessionLogService.ts. I have a small fix with a regression test and a changeset ready.

Contribution

  • I am willing to submit a PR for this bug fix myself (please wait for maintainer approval in this issue first)

Activity

  1. mertkayacs commented on Oct 29, 2026

    @mertkayacs
    Author

    Small follow-up: I have the fix ready on my fork (strict parsing for the numeric KIMI_LOG_* values, malformed input is ignored instead of applied by prefix, with a test for the cases above). Per the contributing guide I am waiting for a maintainer /approve here before opening the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions