Skip to content

Conversation

@codefromthecrypt
Copy link

ACP lacks a stat API, so agents check file existence by attempting to read. When writing a new file, this returns -32002 which is expected behavior, not an error. Log these at debug level to reduce noise.

Also adds ErrorCode constant for self-documenting error code checks.

ACP lacks a stat API, so agents check file existence by attempting
to read. When writing a new file, this returns -32002 which is expected
behavior, not an error. Log these at debug level to reduce noise.

Also adds ErrorCode constant for self-documenting error code checks.
// RESOURCE_NOT_FOUND is expected when checking file existence
// before write, since ACP has no stat API
if (error.code === ErrorCode.RESOURCE_NOT_FOUND) {
console.debug(context, message, error);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this matter though? stdout is for ACP messages, and all logs need to go out on stderr (most agents end up pointing console.debug to console.error for this reason)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so gemini-cli reads before writes at the moment (to create a diff for the permission approval), so there's a bit of spam every time it tries to create a new file... I'm not really used to seeing scary things for common issues.. any ideas on this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or are you saying that console.debug will always be written to stderr anyway.. basically I'm open to options I may not have the best solution in mind.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for gemini cli + claude code all console logs are routed to stderr, otherwise they would be sent over stdout to the ACP client

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I meant to ask if there is a better way to deprioritize this type of log message.. assuming any log has to go to stderr or otherwise not stdout. Or if we should close this PR and just accept that a resource not found due to "check before write" will have this effect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean... it is a good question... these messages are kind of already in the stdin feed.

I could see this as something we filter out. But I guess I can also see cases where this error is helpful for other reasons..

It is also on my todo list somewhere to add a stat api to ACP because it would be useful in more than just this case :D

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.

2 participants