Skip to content

refactor: invert tau_agent/tau_ai dependency to break import cycle#332

Open
Shravanth007 wants to merge 1 commit into
huggingface:mainfrom
Shravanth007:fix/317-decycle-tau-agent-tau-ai
Open

refactor: invert tau_agent/tau_ai dependency to break import cycle#332
Shravanth007 wants to merge 1 commit into
huggingface:mainfrom
Shravanth007:fix/317-decycle-tau-agent-tau-ai

Conversation

@Shravanth007

Copy link
Copy Markdown

tau_agent.loop and tau_agent.harness imported ModelProvider, CancellationToken, and the Provider*Event types from tau_ai, while every tau_ai adapter imports message/tool types from tau_agent — a two-way package cycle contradicting the documented one-way layering.

Apply dependency inversion: the portable core now defines the provider contract (tau_agent/provider.py, tau_agent/provider_events.py) and tau_ai implements it. tau_ai.provider and tau_ai.events become pure re-export shims so all existing call sites keep working, and the classes remain the same objects so isinstance dispatch in the loop is unaffected.

Add tests/test_layering.py guarding the boundary and class identity, and update the README/architecture docs to describe the inward-pointing dependency direction.

Refs #317

tau_agent.loop and tau_agent.harness imported ModelProvider,
CancellationToken, and the Provider*Event types from tau_ai, while every
tau_ai adapter imports message/tool types from tau_agent — a two-way
package cycle contradicting the documented one-way layering.

Apply dependency inversion: the portable core now defines the provider
contract (tau_agent/provider.py, tau_agent/provider_events.py) and tau_ai
implements it. tau_ai.provider and tau_ai.events become pure re-export
shims so all existing call sites keep working, and the classes remain the
same objects so isinstance dispatch in the loop is unaffected.

Add tests/test_layering.py guarding the boundary and class identity, and
update the README/architecture docs to describe the inward-pointing
dependency direction.

Refs huggingface#317
Copilot AI review requested due to automatic review settings July 10, 2026 12:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Shravanth007

Copy link
Copy Markdown
Author

@alejandro-ao do check this PR! .Thanks , and let me know if there is anything else need to be done here

@rian-dolphin rian-dolphin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PR #375 has done some of this it seems

@rian-dolphin rian-dolphin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are some docs corrections here that and better tests though that could be carried on in a fresh PR.

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.

4 participants