Skip to content

Commit eb2a4b4

Browse files
committed
Apply PR aliasrobotics#389: Debug Dockerfile
1 parent 7842160 commit eb2a4b4

7 files changed

Lines changed: 44 additions & 35 deletions

File tree

.github/instructions/todos.instructions.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22
applyTo: '**'
33
---
44

5-
<todos title="Apply PRs #413 and #411 - handle missing API key & fix_message_list" agentRequirement="Review steps frequently throughout the conversation and DO NOT stop between steps unless they explicitly require it. Keep the todos updated using the todo_write tool (do not edit this file).">
6-
- [x] apply-pr-413: Apply PR #413 changes to src/cai/agents/__init__.py (handle missing OpenAI API key gracefully) 🔴
7-
- [x] run-import-checks: Run import/compile checks for modified modules 🟡
8-
- [ ] run-tests: Run project's test suite (pytest) and report failures 🟡
9-
- [ ] push-changes: Push changes to fork remote and create a PR branch 🟢
10-
- [x] apply-pr-411: Apply PR #411 changes: fix infinite loop in fix_message_list and add reordering tests 🔴
11-
- [x] run-import-checks-411: Run import/compile checks for modified modules after PR #411 changes 🟡
12-
- [x] run-tests-411: Run tests/test_fix_message_list_reorder.py and report results 🟡
13-
- [ ] push-changes-411: Push PR #411 changes to fork remote and create PR branch 🟢
5+
<todos title="Fix duplicate context display + apply PR #389" agentRequirement="Review steps frequently throughout the conversation and DO NOT stop between steps unless they explicitly require it. Keep the todos updated using the todo_write tool (do not edit this file).">
6+
- [x] investigate-duplicate-context: Investigate duplicate 'Context' status appearing in stream UI 🔴
7+
_Found duplicated context in both header tokens_text and footer compact_tokens_
8+
- [x] add-include-context-flag: Add `include_context` flag to `_create_token_display` to make header context optional 🟡
9+
_Implemented optional flag to avoid duplicating context indicator when footer has compact info_
10+
- [x] suppress-header-context-in-streaming: Call `_create_token_display(..., include_context=False)` in streaming final_stats path 🟡
11+
_Updated streaming final_stats call to suppress header context when footer compact tokens are present_
12+
- [ ] verify-change: Run quick visual check / focused test to ensure duplicate context removed from streaming output 🔴
13+
_Recommend running a focused run that produces streaming output to visually confirm; can run `pytest -q tests/test_fix_message_list_reorder.py` or start an agent stream locally_
14+
- [-] apply-pr-389: Fetch and apply PR #389 changes (dockerized/Dockerfile) 🟡
15+
_Added Kali mirror fix to dockerized/Dockerfile per upstream PR #389_
16+
- [ ] commit-push-pr-389: Commit the applied PR changes and push to fork/branch for review 🟡
17+
_Commit message: Apply PR #389: Debug Dockerfile; push to giveen/buggy or create branch_
1418
</todos>
1519

1620
<!-- Auto-generated todo section -->

dockerized/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ FROM kalilinux/kali-rolling
22

33
ENV DEBIAN_FRONTEND=noninteractive
44

5+
# [FIX BAD MIRROR] Use a single, reliable Kali mirror to avoid flaky mirror redirects during apt operations
6+
RUN printf 'deb http://kali.download/kali kali-rolling main contrib non-free non-free-firmware\n' > /etc/apt/sources.list
7+
58
# Fix Kali GPG Keys
69
RUN apt-get update --allow-insecure-repositories && \
710
apt-get install -y --no-install-recommends --allow-unauthenticated kali-archive-keyring && \

docs/cai/getting-started/commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ cai
366366
/mcp load http://localhost:9876/sse burp
367367

368368
# Add MCP tools to agent
369-
/mcp add-to-agent <agent_name> burp
369+
/mcp add burp <agent_name>
370370

371371
# Set up virtualized environment
372372
/virtualization create ubuntu:latest

docs/cli/advanced_usage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ burp-mcp-server --port 9876
11431143
# In CAI
11441144
CAI> /mcp load http://localhost:9876/sse burp
11451145
CAI> /mcp tools burp
1146-
CAI> /mcp add redteam_agent burp
1146+
CAI> /mcp add burp redteam_agent
11471147
11481148
# Use Burp tools
11491149
CAI> Use Burp to scan https://target.com
@@ -1156,7 +1156,7 @@ CAI> Use Burp to scan https://target.com
11561156
CAI> /mcp load stdio "python my_custom_tools.py" custom
11571157
11581158
# Add to agent
1159-
CAI> /mcp add bug_bounter_agent custom
1159+
CAI> /mcp add custom bug_bounter_agent
11601160
11611161
# Use custom tools
11621162
CAI> Use custom scanner on target

docs/cli/commands_reference.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,11 +635,11 @@ List active MCP connections.
635635
/mcp list
636636
```
637637

638-
#### `add <agent_name> <server_name>`
638+
#### `add <server_name> <agent_name>`
639639
Add MCP tools to an agent.
640640

641641
```bash
642-
/mcp add redteam_agent burp
642+
/mcp add burp redteam_agent
643643
```
644644

645645
#### `remove <server_name>`
@@ -680,7 +680,7 @@ CAI> /mcp load http://localhost:9876/sse burp
680680
CAI> /mcp tools burp
681681

682682
# Add to current agent
683-
CAI> /mcp add redteam_agent burp
683+
CAI> /mcp add burp redteam_agent
684684

685685
# Check status
686686
CAI> /mcp status

src/cai/sdk/agents/models/openai_chatcompletions.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3673,8 +3673,7 @@ async def _fetch_response_litellm_openai(
36733673
"""
36743674
try:
36753675
if stream:
3676-
# Standard LiteLLM handling for streaming
3677-
ret = await litellm.acompletion(**kwargs)
3676+
# Standard LiteLLM handling for streaming — make a single streaming call
36783677
stream_obj = await litellm.acompletion(**kwargs)
36793678

36803679
response = Response(
@@ -3728,7 +3727,7 @@ async def _fetch_response_litellm_openai(
37283727
kwargs["messages"] = messages
37293728
# Retry once, silently
37303729
if stream:
3731-
ret = await litellm.acompletion(**kwargs)
3730+
# Retry streaming call once (single request)
37323731
stream_obj = await litellm.acompletion(**kwargs)
37333732
response = Response(
37343733
id=FAKE_RESPONSES_ID,

src/cai/util.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,7 @@ def _create_token_display(
16151615
model,
16161616
interaction_cost=None,
16171617
total_cost=None,
1618+
include_context: bool = True,
16181619
) -> Text:
16191620
# Standardize model name
16201621
model_name = get_model_name(model)
@@ -1661,24 +1662,25 @@ def _create_token_display(
16611662
tokens_text.append("Session: ", style="bold magenta")
16621663
tokens_text.append(f"${COST_TRACKER.session_total_cost:.4f}", style="bold magenta")
16631664

1664-
# Context usage
1665-
tokens_text.append(" | ", style="dim")
1666-
context_pct = interaction_input_tokens / get_model_input_tokens(model_name) * 100
1667-
tokens_text.append("Context: ", style="bold")
1668-
tokens_text.append(f"{context_pct:.1f}% ", style="bold")
1669-
1670-
# Context indicator
1671-
if context_pct < 50:
1672-
indicator = "🟩"
1673-
color_local = "green"
1674-
elif context_pct < 80:
1675-
indicator = "🟨"
1676-
color_local = "yellow"
1677-
else:
1678-
indicator = "🟥"
1679-
color_local = "red"
1665+
# Context usage (optional)
1666+
if include_context:
1667+
tokens_text.append(" | ", style="dim")
1668+
context_pct = interaction_input_tokens / get_model_input_tokens(model_name) * 100
1669+
tokens_text.append("Context: ", style="bold")
1670+
tokens_text.append(f"{context_pct:.1f}% ", style="bold")
1671+
1672+
# Context indicator
1673+
if context_pct < 50:
1674+
indicator = "🟩"
1675+
color_local = "green"
1676+
elif context_pct < 80:
1677+
indicator = "🟨"
1678+
color_local = "yellow"
1679+
else:
1680+
indicator = "🟥"
1681+
color_local = "red"
16801682

1681-
tokens_text.append(f"{indicator}", style=color_local)
1683+
tokens_text.append(f"{indicator}", style=color_local)
16821684

16831685
return tokens_text
16841686

@@ -2539,6 +2541,7 @@ def finish_agent_streaming(context, final_stats=None):
25392541
model_name, # string model name!
25402542
interaction_cost,
25412543
total_cost,
2544+
include_context=False,
25422545
)
25432546

25442547
# Crear una línea de tokens compacta para el streaming

0 commit comments

Comments
 (0)