Skip to content

fix(ckg): accept file path for ckg tool and clarify path parameter - #426

Open
nankingjing wants to merge 1 commit into
bytedance:mainfrom
nankingjing:fix/ckg-path-to-file
Open

fix(ckg): accept file path for ckg tool and clarify path parameter#426
nankingjing wants to merge 1 commit into
bytedance:mainfrom
nankingjing:fix/ckg-path-to-file

Conversation

@nankingjing

@nankingjing nankingjing commented Jul 10, 2026

Copy link
Copy Markdown

Summary

The ckg tool's path parameter description was ambiguous ("The path to the codebase."), leading some models (e.g. Doubao, see #354) to pass a file path instead of the codebase directory. This caused a hard failure (Codebase path X is not a directory) and the CKG was never initialized, so search_function / search_class / search_class_method could not be used at all.

Changes

  1. Clarify the path parameter description — it now explicitly states a directory (the codebase root) is required, and documents the file-path fallback. This is the root cause: the ambiguous description misled the model.
  2. Defensive fallback in execute() — if a file path is passed and the file exists, resolve to its parent directory so the CKG index can still be built. Other non-directory paths (e.g. broken symlinks) still return the original clear error.

Why this is correct

  • CKGDatabase.__init__ indexes via Path.glob("**/*"), so it needs a directory; passing the parent directory of the intended file is exactly what it expects.
  • The fallback uses standard pathlib.Path.is_file() / .parent semantics and only triggers when the path exists but is not a directory, so existing directory behavior is unchanged.
  • The _ckg_databases cache keys on the resolved directory Path, keeping caching consistent.

Fixes #354

The ckg tool's 'path' parameter description was ambiguous ('The path to
the codebase.'), leading some models (e.g. Doubao) to pass a file path
instead of the codebase directory. This caused a hard failure ('Codebase
path X is not a directory') and the CKG was never initialized.

Clarify the parameter description to state a directory is required, and,
when a file path is passed anyway, fall back to its parent directory so
the index can still be built.

Fixes bytedance#354
@nankingjing

Copy link
Copy Markdown
Author

Reviewed — the fallback to parent directory when a file path is given is a clean defensive fix for the CKG tool. Ready for review.

@nankingjing

Copy link
Copy Markdown
Author

@chao-peng ready for review. Fixes CKG tool accepting a file path: falls back to parent directory when path is a file, and clarifies the path parameter description.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ckg not working, it will be never initialized where using doubao 1.6 to search function

1 participant