Skip to content

Warn users when instrumentation is used before ag.init(), Previously,…#4098

Draft
Excali556 wants to merge 4 commits intoAgenta-AI:mainfrom
Excali556:fix-init-warning
Draft

Warn users when instrumentation is used before ag.init(), Previously,…#4098
Excali556 wants to merge 4 commits intoAgenta-AI:mainfrom
Excali556:fix-init-warning

Conversation

@Excali556
Copy link
Copy Markdown

@Excali556 Excali556 commented Apr 1, 2026

(Fixes #3170 )
Previously, calling tracing or instrumentation methods before ag.init() failed silently, making it difficult for users to understand why instrumentation was not working.

This PR adds a warning when such methods are used before initialization, guiding users to call ag.init() first.

Summary

  • Adds a helper to detect whether the SDK has been initialized
  • Emits a warning when tracing/instrumentation methods are used before ag.init()
  • Ensures the warning is logged only once to avoid noise

Testing

Verified locally

  • Ran python -m compileall . to ensure no syntax errors
  • Manually verified that a warning is logged when calling tracing methods before ag.init()

Added or updated tests

N/A

QA follow-up

N/A

Demo

N/A

Checklist

  • I have included a video or screen recording for UI changes, or marked Demo as N/A
  • Relevant tests pass locally
  • Relevant linting and formatting pass locally
  • I have signed the CLA, or I will sign it when the bot prompts me

… calling tracing/instrumentation methods before initialization failed silently. This adds a clear warning to guide users to call ag.init() first.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 1, 2026

@Excali556 is attempting to deploy a commit to the agenta projects Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 1, 2026
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 1, 2026

CLA assistant check
All committers have signed the CLA.

@dosubot dosubot bot added the dev experience Improvement of the experience using the software. For instance better error messaging label Apr 1, 2026
@jp-agenta
Copy link
Copy Markdown
Member

Hi @Excali556 ,

This PR looks like a duplicate from the other one.
Could you please unify them ?

@Excali556
Copy link
Copy Markdown
Author

Hi @Excali556 ,

This PR looks like a duplicate from the other one. Could you please unify them ?

Sure

@jp-agenta
Copy link
Copy Markdown
Member

Also @Excali556 ,
There was an open question in the other PR.
Could you please respond to it in this PR ?

@Excali556
Copy link
Copy Markdown
Author

Also @Excali556 , There was an open question in the other PR. Could you please respond to it in this PR ?

Sure.

The idea was mainly to make it more visible to users. The existing log.info can be easy to miss, especially since info logs aren’t always surfaced. Since calling instrumentation before ag.init() can lead to confusing behavior, I thought a warning would make it clearer that something’s off, without breaking anything. So it’s mostly about making the issue easier to notice and act on.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 1, 2026
@Excali556 Excali556 marked this pull request as draft April 3, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev experience Improvement of the experience using the software. For instance better error messaging size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[chore] Add warning when ag.init() is called and API key is not set

3 participants