Skip to content
Open
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 implementations/energy_oil_forecasting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WTI Crude Oil is highly liquid and sensitive to geopolitical risk, macroeconomic

1. **Statistical models** (Prophet) extrapolate trend and seasonality but are blind to regime-breaking news.
2. **Context-aware agentic models** (bounded Google Search) adapt to shocks by reasoning over shipping lane closures, OPEC+ policy, and political escalation.
3. **Code-executing agentic models** verify trends, compute rolling indicators, and self-calibrate intervals via sandboxed Python.
3. **Code-executing agentic models** verify trends, compute rolling indicators, and self-calibrate intervals via self-contained sandboxed Python scripts with explicit imports.

---

Expand Down
13 changes: 7 additions & 6 deletions implementations/energy_oil_forecasting/analyst_agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ def _build_wti_analyst_instruction() -> str:
3. Call `load_skill_resource(<skill_name>, <file_path>)` to load a
reference file (e.g. `references/wti_benchmarks.json`).

Every `run_code` call must be a complete, self-contained Python script:
include every import used in that same script. In particular, include
`import json` whenever serializing results with `json.dumps`; do not rely on
imports from an earlier call.

These skills have NO scripts. Do not call `run_skill_script`.\
"""

Expand Down Expand Up @@ -534,9 +539,7 @@ def build_wti_code_exec_config(
return AgentConfig(
name="wti_analyst_code",
model=model,
instruction=(
_WTI_ANALYST_INSTRUCTION + _CONTEXT_RETRIEVAL_SUPPLEMENT + _CODE_EXEC_SKILLS_SUPPLEMENT
),
instruction=(_WTI_ANALYST_INSTRUCTION + _CONTEXT_RETRIEVAL_SUPPLEMENT + _CODE_EXEC_SKILLS_SUPPLEMENT),
max_output_tokens=max_output_tokens,
context_retrieval=ContextRetrievalConfig(
enabled=True,
Expand Down Expand Up @@ -611,9 +614,7 @@ def build_wti_tool_config(
return AgentConfig(
name="wti_analyst_tool",
model=model,
instruction=(
_WTI_ANALYST_INSTRUCTION + _CONTEXT_RETRIEVAL_SUPPLEMENT + _FORECAST_TOOL_SUPPLEMENT
),
instruction=(_WTI_ANALYST_INSTRUCTION + _CONTEXT_RETRIEVAL_SUPPLEMENT + _FORECAST_TOOL_SUPPLEMENT),
context_retrieval=ContextRetrievalConfig(
enabled=True,
instruction=_WTI_CONTEXT_RETRIEVAL_INSTRUCTION,
Expand Down
12 changes: 12 additions & 0 deletions implementations/tests/energy_oil_forecasting/test_analyst_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Tests for the WTI analyst agent configurations."""

from energy_oil_forecasting.analyst_agent import build_wti_code_exec_config


def test_code_exec_instruction_requires_self_contained_imports() -> None:
"""Generated sandbox scripts must import modules used for serialization."""
instruction = build_wti_code_exec_config().instruction

assert "include every import" in instruction
assert "import json" in instruction
assert "json.dumps" in instruction