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
9 changes: 8 additions & 1 deletion libs/code/deepagents_code/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,9 @@ def build_stream_config(
This describes the Deep Agents package installed alongside the TUI, which
can differ from a remote graph's Deep Agents runtime version.

Also records `dcode_experimental=True` when `DEEPAGENTS_CODE_EXPERIMENTAL`
is enabled, so experimental runs are filterable in trace metadata.

Args:
thread_id: The app session thread identifier. Set both on
`configurable.thread_id` and as the top-level `metadata.thread_id`
Expand All @@ -1699,7 +1702,7 @@ def build_stream_config(
logger.warning("Could not determine working directory", exc_info=True)
cwd = ""

from deepagents_code._env_vars import USER_ID
from deepagents_code._env_vars import EXPERIMENTAL, USER_ID

metadata: dict[str, Any] = build_coding_agent_metadata(
thread_id=thread_id,
Expand All @@ -1711,6 +1714,10 @@ def build_stream_config(
user_id=os.environ.get(USER_ID) or None,
)

# Mark experimental runs so they are filterable in trace metadata.
if is_env_truthy(EXPERIMENTAL):
metadata["dcode_experimental"] = True

# Legacy / diagnostic keys preserved for backward-compatibility during the
# coding-agent-v1 rollout (not part of the contract).
metadata["lc_versions"] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ async def test_scroll_down_hydrates_tail_below(
# Archive the newest rows below the window (the state after the user
# has scrolled up and older history was mounted in their place).
monkeypatch.setattr(app._message_store, "WINDOW_SIZE", 3)
monkeypatch.setattr(app._message_store, "HYDRATE_BUFFER", 2)
monkeypatch.setattr(app._message_store, "HYDRATE_BUFFER", 20)
messages = app.query_one("#messages", Container)
await app._prune_messages_below_window(messages)
await pilot.pause()
Expand Down
20 changes: 20 additions & 0 deletions libs/code/tests/unit_tests/tui/test_textual_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,26 @@ def test_user_id_absent_when_unset(self) -> None:
config = build_stream_config("t-nouid", assistant_id=None)
assert "user_id" not in config["metadata"]

def test_experimental_included_when_enabled(self) -> None:
"""Experimental runs should be identifiable in trace metadata."""
with patch.dict("os.environ", {"DEEPAGENTS_CODE_EXPERIMENTAL": "true"}):
config = build_stream_config("t-experimental", assistant_id=None)
assert config["metadata"]["dcode_experimental"] is True

def test_experimental_absent_when_disabled(self) -> None:
"""Default runs should not be labeled experimental."""
with patch.dict("os.environ", {"DEEPAGENTS_CODE_EXPERIMENTAL": "false"}):
config = build_stream_config("t-stable", assistant_id=None)
assert "dcode_experimental" not in config["metadata"]

def test_experimental_absent_when_unset(
self, monkeypatch: pytest.MonkeyPatch
) -> None:
"""The default path (env var unset) is not labeled experimental."""
monkeypatch.delenv("DEEPAGENTS_CODE_EXPERIMENTAL", raising=False)
config = build_stream_config("t-default", assistant_id=None)
assert "dcode_experimental" not in config["metadata"]


class TestGetGitBranch:
"""Tests for `_get_git_branch` caching."""
Expand Down
Loading