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
39 changes: 39 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ jobs:
deps_changed: ${{ steps.check.outputs.deps_changed }}
cuvs_changed: ${{ steps.check.outputs.cuvs_changed }}
langchain_changed: ${{ steps.check.outputs.langchain_changed }}
bot_changed: ${{ steps.check.outputs.bot_changed }}
steps:
- uses: actions/checkout@v6
with:
Expand Down Expand Up @@ -152,6 +153,20 @@ jobs:
echo "langchain_changed=false" >> $GITHUB_OUTPUT
fi

# Run the VikingBot unit test suites when bot code, its dependency
# set, or this workflow change.
BOT_PATTERN="^bot/|pyproject\.toml|uv\.lock|\.github/workflows/pr\.yml"
BOT_CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }} HEAD | grep -E "$BOT_PATTERN" || true)

if [ -n "$BOT_CHANGED_FILES" ]; then
echo "Bot changes detected:"
echo "$BOT_CHANGED_FILES"
echo "bot_changed=true" >> $GITHUB_OUTPUT
else
echo "No bot changes detected."
echo "bot_changed=false" >> $GITHUB_OUTPUT
fi

build:
needs: check-deps
if: ${{ needs.check-deps.outputs.deps_changed == 'true' }}
Expand All @@ -165,6 +180,30 @@ jobs:
os_json: '["ubuntu-24.04"]'
python_json: '["3.11"]'

bot-tests:
needs: check-deps
if: ${{ needs.check-deps.outputs.bot_changed == 'true' }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- uses: actions/setup-python@v6
with:
python-version: '3.12'

- uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Install bot dependencies
run: uv sync --frozen --extra bot --extra test

- name: Run VikingBot unit tests
run: |
uv run python -m pytest -q -o addopts='' bot/tests bot/vikingbot

langchain-tests:
needs: check-deps
if: ${{ needs.check-deps.outputs.langchain_changed == 'true' }}
Expand Down
19 changes: 12 additions & 7 deletions bot/tests/test_agent_loop_outcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,12 @@ async def execute(self, tool_name, arguments, **kwargs):
"tool result: useful context",
"tool result: useful context",
]
assert token_usage == {"prompt_tokens": 17, "completion_tokens": 7, "total_tokens": 24}
assert token_usage == {
"prompt_tokens": 17,
"completion_tokens": 7,
"total_tokens": 24,
"cache_read_input_tokens": 0,
}


@pytest.mark.asyncio
Expand All @@ -643,7 +648,7 @@ async def fake_run_agent_loop(self, **kwargs):
agents={
"session_context_enabled": True,
"commit_token_threshold": 1,
"commit_keep_recent_count": 0,
"commit_keep_recent_turn_count": 0,
},
)
loop = AgentLoop(
Expand Down Expand Up @@ -1031,7 +1036,7 @@ async def fake_execute_hooks(context, **kwargs):
(
"hook",
kwargs["force_commit"],
kwargs.get("keep_recent_count"),
kwargs.get("keep_recent_turn_count"),
kwargs.get("commit_message_threshold"),
)
)
Expand Down Expand Up @@ -1078,7 +1083,7 @@ async def fake_run_agent_loop(self, **kwargs):
"session_context_enabled": True,
"session_context_token_budget": 321,
"commit_token_threshold": 100,
"commit_keep_recent_count": 2,
"commit_keep_recent_turn_count": 2,
},
)
loop = AgentLoop(
Expand Down Expand Up @@ -1137,7 +1142,7 @@ async def fake_execute_hooks(context, **kwargs):
(
"hook",
kwargs["force_commit"],
kwargs.get("keep_recent_count"),
kwargs.get("keep_recent_turn_count"),
kwargs.get("commit_message_threshold"),
)
)
Expand Down Expand Up @@ -1182,7 +1187,7 @@ async def fake_run_agent_loop(self, **kwargs):
"session_context_enabled": True,
"session_context_token_budget": 321,
"commit_token_threshold": 1000,
"commit_keep_recent_count": 2,
"commit_keep_recent_turn_count": 2,
},
)
loop = AgentLoop(
Expand Down Expand Up @@ -1249,7 +1254,7 @@ async def fake_execute_hooks(context, **kwargs):
agents={
"session_context_enabled": True,
"commit_token_threshold": 1000,
"commit_keep_recent_count": 2,
"commit_keep_recent_turn_count": 2,
},
)
loop = AgentLoop(
Expand Down
2 changes: 1 addition & 1 deletion bot/tests/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@ def test_compile_prompt_describes_editable_target_checkout():
assert "update existing files in place" in system
assert "submit_wiki_bundle with no arguments" in system
assert "complete UTF-8 OKF Markdown file" in system
assert "commits only validated changes" in system
assert "scans and validates the complete tree" in system
assert "Inspect the editable target checkout" in user


Expand Down
Loading