Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install package and test deps
run: |
pip install -e .
pip install pytest pytest-cov pydantic-ai
pip install pytest pytest-cov pydantic-ai crewai

- name: Run unit tests with coverage
run: |
Expand Down
53 changes: 53 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Agent Guidelines

## Running Tests

**IMPORTANT:** Always run tests after making code changes to verify they work correctly.

### Running Tests

```bash
# Activate the virtual environment first
source /Users/tgillam/code/gradient-adk/env/bin/activate

# Run all tests
python -m pytest tests/ -v

# Run a specific test file
python -m pytest tests/runtime/test_crewai/crewai_instrumentor_test.py -v

# Run a specific test
python -m pytest tests/runtime/test_crewai/crewai_instrumentor_test.py::test_install_sets_installed_flag -v

# Run tests without coverage (faster)
python -m pytest tests/ -v --no-cov
```

### Test Directory Naming

**CRITICAL:** Test directories must NOT have the same name as Python packages being tested.

For example:
- BAD: `tests/runtime/crewai/` - This shadows the real `crewai` package!
- GOOD: `tests/runtime/test_crewai/` - This doesn't conflict with the real package.

When pytest runs, it adds test directories to `sys.path`. If a test directory has the same name as an installed package, Python will import the test directory instead of the real package, causing import errors like "No module named 'package.submodule'".

### Dependencies

Some tests require optional dependencies:
- `crewai` - For CrewAI instrumentor tests
- `pydantic-ai` - For PydanticAI instrumentor tests

Install optional test dependencies:
```bash
pip install crewai pydantic-ai
```

### Environment Variables for Integration Tests

Some integration tests require environment variables:
- `RUN_E2E_TESTS=1` - Enable E2E tests
- `RUN_DEPLOY_TESTS=1` - Enable deployment tests
- `GRADIENT_MODEL_ACCESS_KEY` - For LLM API calls
- `SERPER_API_KEY` - For search tool tests
2 changes: 2 additions & 0 deletions gradient_adk/digital_ocean_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
ToolSpanDetails,
RetrieverSpanDetails,
WorkflowSpanDetails,
AgentSpanDetails,
Span,
Trace,
CreateTracesInput,
Expand Down Expand Up @@ -48,6 +49,7 @@
"ToolSpanDetails",
"RetrieverSpanDetails",
"WorkflowSpanDetails",
"AgentSpanDetails",
"Span",
"Trace",
"CreateTracesInput",
Expand Down
15 changes: 14 additions & 1 deletion gradient_adk/digital_ocean_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ class WorkflowSpanDetails(BaseModel):
spans: List["Span"] = Field(default_factory=list, description="Nested sub-spans")


class AgentSpanDetails(BaseModel):
"""Agent span containing nested sub-spans for LLM and tool calls."""

model_config = ConfigDict(populate_by_name=True, extra="allow")

common: Optional[SpanCommon] = None
spans: List["Span"] = Field(default_factory=list, description="Nested sub-spans")


class Span(BaseModel):
"""
Represents a span within a trace (e.g., LLM call, retriever, tool, workflow).
Expand Down Expand Up @@ -99,10 +108,14 @@ class Span(BaseModel):
workflow: Optional[WorkflowSpanDetails] = Field(
None, description="Workflow span with nested sub-spans"
)
agent: Optional[AgentSpanDetails] = Field(
None, description="Agent span with nested sub-spans"
)


# Update forward reference for WorkflowSpanDetails
# Update forward references for nested span details
WorkflowSpanDetails.model_rebuild()
AgentSpanDetails.model_rebuild()


class Trace(BaseModel):
Expand Down
5 changes: 5 additions & 0 deletions gradient_adk/runtime/crewai/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""CrewAI instrumentation for Gradient ADK."""

from .crewai_instrumentor import CrewAIInstrumentor

__all__ = ["CrewAIInstrumentor"]
Loading