Skip to content

Support for multi-thread in Opik#6

Merged
pmenendz merged 2 commits intomainfrom
multi-thread-opik
Jun 25, 2025
Merged

Support for multi-thread in Opik#6
pmenendz merged 2 commits intomainfrom
multi-thread-opik

Conversation

@pmenendz
Copy link
Copy Markdown
Collaborator

No description provided.

@pmenendz pmenendz requested a review from Copilot June 25, 2025 16:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces multi-thread support for Opik tracing by decoupling tracer instantiation from setup and creating per-thread tracer instances.

  • Store the Opik configuration in the agent and defer tracer creation.
  • Add _create_opik_tracer to instantiate a tracer for each thread.
  • Update get_response to attach a thread-specific tracer callback.
Comments suppressed due to low confidence (3)

src/expert/agent.py:104

  • Add unit tests for _create_opik_tracer to verify it returns None when opik_config is unset and correctly instantiates an OpikTracer with the expected tags.
    def _create_opik_tracer(self, user_thread_id: str) -> OpikTracer | None:

src/expert/agent.py:115

  • Verify that OpikTracer accepts a tags parameter in this form; if it expects metadata key/value pairs, you may need to pass a dict like tags={"thread_id": user_thread_id}.
            tags=[user_thread_id]

src/expert/agent.py:130

  • [nitpick] Consider caching tracer instances per thread_id to avoid recreating them on each request, which could reduce overhead.
        tracer = self._create_opik_tracer(thread_id)

Comment thread src/expert/agent.py Outdated
Comment thread src/expert/agent.py
@pmenendz pmenendz merged commit 8d734ae into main Jun 25, 2025
6 checks passed
@pmenendz pmenendz deleted the multi-thread-opik branch June 25, 2025 16:52
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