4 small bugs found while reading the code — happy to fixing suggestion #4077
topstar-ai
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi camel team 👋
Was reading through the codebase this week and ran into 4 small bugs.
Fixes are short in each case.
Retry backoff in ChatAgent isn't really exponential** (reliability)
delay = min(retry_delay * 2**attempt, 60)is immediately followed bydelay = random.uniform(0, delay)— sleeps can land near zero on any attempt.If full jitter is the intent that's fine, but as written the exponential part doesn't really kick in.
ShareGPT collector exports wrong JSON** (data export)
ensure_ascii=Falseis being passed todict(...)instead of the innerjson.dumps. Non-ASCII gets escaped and the output dict ends up with a stray"ensure_ascii": falsefield.Unreachable elif in the Anthropic converter** (dead code)
elif isinstance(response.content, str)only runs whenhasattr(response, "content")is false — at which point readingresponse.contentwould AttributeError. Probably meant to be inside theif-branch.Leaked file handles in speech_to_text** (resource leak)
Two
open(path, "rb")calls aren't wrapped inwith. On Windows that also makes theos.remove(chunk_path)right after occasionally fail.Checked open PRs — #3974 / #3958 / #3949 touch retry exception handling but not the jitter math, so no overlap.
If allow. I will fix these and submit.
Thanks
All reactions