Skip to content

ui update - #3

Open
Apsinghsa wants to merge 5 commits into
mainfrom
mac
Open

ui update#3
Apsinghsa wants to merge 5 commits into
mainfrom
mac

Conversation

@Apsinghsa

@Apsinghsa Apsinghsa commented Apr 19, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

Release Notes

  • New Features

    • New comparison UI for evaluating travel agents side-by-side
    • Session reset functionality to clear conversation history
  • Improvements

    • Upgraded to more capable AI model for enhanced planning
    • Enhanced tool argument validation and error recovery mechanisms
    • Improved safety guardrails for travel recommendations
    • Refined prompts for clearer tool usage and parameter guidance

@coderabbitai

coderabbitai Bot commented Apr 19, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Updated Chroma database path configuration to use absolute paths in memory modules. Significantly refactored travel agents with improved tool schema descriptions, new helper functions for tool error detection and result formatting, upgraded Groq model version, and refined constraint handling logic. Added a new Gradio UI for side-by-side comparison of baseline and memory-augmented agents. Updated prompts with increased compression limits and explicit tool parameter rules.

Changes

Cohort / File(s) Summary
Memory Configuration
ccm/episodic_memory.py, ccm/semantic_memory.py
Updated CHROMA_PATH to resolve as absolute path relative to module location instead of fixed relative path, ensuring consistent database directory resolution independent of working directory.
Agent Tool & Logic
travel_agent/agent.py, travel_agent/baseline_agent.py
Refined tool schema descriptions, added defensive type coercion for tool arguments, introduced helper functions for error detection and result formatting, upgraded Groq model to llama-3.3-70b-versatile, adjusted tool round limits, modified error recovery, and updated constraint handling with simplified safety buckets. Added BASELINE_TOOL_INSTRUCTION to baseline agent system prompt.
Agent Prompts
travel_agent/prompts.py
Increased compression limits (100→150 words), removed conservative test instructions, revised constraint-check wording, removed CONTEXT_ASSEMBLY_TEMPLATE, added explicit tool parameter validation rules, updated system prompts to require tool usage for answers, and changed section divider formatting.
UI Interface
ui/app.py
New Gradio application providing side-by-side chat UI comparing BaselineAgent and CCMAgent with persistent-state reset logic, lazy agent initialization, streaming chat generator, and custom UI configuration.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant UI as Gradio UI
    participant BA as BaselineAgent
    participant CA as CCMAgent
    participant LLM as Groq LLM
    participant Tools as Tool Executor
    participant DB as ChromaDB

    User->>UI: Submit message
    UI->>BA: chat(user_message)
    activate BA
    BA->>LLM: Call model with tools enabled
    activate LLM
    LLM-->>BA: Tool call request
    deactivate LLM
    BA->>Tools: execute_tool()
    Tools->>Tools: Coerce arguments, format result
    Tools-->>BA: Formatted result
    BA->>BA: _format_result_for_llm()
    BA->>LLM: Call model with tool result
    activate LLM
    LLM-->>BA: Response or retry
    deactivate LLM
    BA-->>UI: Agent response
    deactivate BA

    UI->>CA: chat(user_message)
    activate CA
    CA->>DB: Query episodic/semantic memory
    DB-->>CA: Compressed context
    CA->>CA: _build_clean_context()
    CA->>LLM: Call model with memory context
    activate LLM
    LLM-->>CA: Tool call request
    deactivate LLM
    CA->>Tools: execute_tool()
    Tools-->>CA: Formatted result
    CA->>LLM: Call model with tool result
    activate LLM
    LLM-->>CA: Response
    deactivate LLM
    CA-->>UI: Agent response
    deactivate CA

    UI->>UI: Update both chat histories
    UI-->>User: Display side-by-side comparison
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 Agents now chat side by side,
Memory paths find home with pride,
Tools reformed with better care,
Prompts refined, logic fair,
Groq's newest joins the fray! 🎉

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'ui update' is overly vague and generic. While a UI file (ui/app.py) was added, the PR includes substantial changes across 5 files: ChromaDB path fixes, agent logic refactoring, and prompt improvements. Use a more descriptive title that captures the main changes, such as 'Add comparative agent UI and refactor tool execution' or 'Implement side-by-side agent comparison UI with ChromaDB and agent improvements'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mac
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch mac

Comment @coderabbitai help to get the list of available commands and usage tips.

@Apsinghsa

Copy link
Copy Markdown
Collaborator Author

@copilot resolve the merge conflicts in this pull request

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (8)
travel_agent/baseline_agent.py (1)

166-177: Redundant tool instructions partially duplicate BASELINE_SYSTEM_PROMPT.

BASELINE_TOOL_INSTRUCTION repeats several rules already present in BASELINE_SYSTEM_PROMPT (lines 421-442 in prompts.py), such as tool mappings and budget_per_night guidance. Consider consolidating to avoid drift.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@travel_agent/baseline_agent.py` around lines 166 - 177,
BASELINE_TOOL_INSTRUCTION duplicates rules already defined in
BASELINE_SYSTEM_PROMPT; remove the redundant lines from
BASELINE_TOOL_INSTRUCTION and consolidate the canonical rules into
BASELINE_SYSTEM_PROMPT (or have BASELINE_TOOL_INSTRUCTION reference
BASELINE_SYSTEM_PROMPT) so there’s a single source of truth; keep any
tool-specific exceptions that truly belong only to tool instructions, update
comments to point to BASELINE_SYSTEM_PROMPT, and ensure the guidance about
omitting budget_per_night unless numeric remains enforced by removing that
clause from BASELINE_TOOL_INSTRUCTION and leaving it only in
BASELINE_SYSTEM_PROMPT.
ccm/semantic_memory.py (1)

60-61: Residual data directory creation is now inconsistent.

Line 61 still creates the data directory, but CHROMA_PATH no longer points inside data/. Consider removing this line or updating it to create the parent of CHROMA_PATH instead.

♻️ Suggested fix
     def __init__(self):
         os.makedirs(CHROMA_PATH, exist_ok=True)
-        os.makedirs("data", exist_ok=True)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ccm/semantic_memory.py` around lines 60 - 61, The code currently calls
os.makedirs("data", exist_ok=True) even though CHROMA_PATH no longer lives under
data; remove that residual directory creation or replace it by creating the
parent directory of CHROMA_PATH instead. Locate the os.makedirs("data",
exist_ok=True) call in semantic_memory.py (near the os.makedirs(CHROMA_PATH,
exist_ok=True) line) and either delete that line or change it to create
os.path.dirname(CHROMA_PATH) (guarding for empty dirname) so only the actual
parent directory of CHROMA_PATH is ensured.
travel_agent/agent.py (2)

151-154: Multiple statements on single lines violate PEP 8 style.

Static analysis flagged several instances of if x: y patterns. While functional, these reduce readability.

♻️ Example fix for one instance (apply pattern throughout)
-                if addr:   line += f", {addr}"
-                if price:  line += f" (${price}/night)"
-                if rating: line += f" star:{rating}"
-                if warning: line += f" | WARNING: {warning}"
+                if addr:
+                    line += f", {addr}"
+                if price:
+                    line += f" (${price}/night)"
+                if rating:
+                    line += f" star:{rating}"
+                if warning:
+                    line += f" | WARNING: {warning}"

Also applies to: 168-169, 178-178, 180-180, 191-191, 229-230, 276-276, 278-278, 289-291

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@travel_agent/agent.py` around lines 151 - 154, Several single-line if
statements (e.g., "if addr: line += f\", {addr}\"", and similar uses for price,
rating, warning that append to the local variable line) violate PEP8; replace
each "if x: y" with a proper multi-line if block so readability is improved (for
example: if addr:\n    line += f\", {addr}\"). Apply this change to all similar
occurrences that append to line (also the other flagged instances that append or
modify variables at lines handling addr/price/rating/warning and the other noted
occurrences), keeping the same condition and mutation but using full if blocks
to match surrounding function logic.

258-295: Constraint enforcement is limited to shellfish allergy only.

_enforce_critical_constraints only handles shellfish allergy despite the prompt referencing general "CRITICAL CONSTRAINTS" (budget limits, activity pace, etc.). Other critical constraints in memory are not enforced.

Would you like me to help extend this function to handle budget constraints and other critical constraint types stored in memory_state.working_memory_raw.facts.critical?

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@travel_agent/agent.py` around lines 258 - 295, _enforce_critical_constraints
currently only checks for shellfish in critical_facts; extend it to iterate over
each fact in memory_state.get("working_memory_raw", {}).get("facts",
{}).get("critical", []) and switch on a fact type (e.g., fact.get("type") or
infer from keys like "value" containing currency or pace indicators) to apply
handlers for other constraint types such as budget and activity pace. For budget
facts, aggregate the user's max budget and filter/annotate places from
tool_calls_this_turn (same "places_search" raw_result parsing used for allergy)
to mark or remove options over budget and add a concise budget warning to parts;
for activity-pace facts, detect pace constraints and add guidance (e.g.,
"low-activity" or "high-activity" suggestions) to parts. Reuse existing
de-duplication (list(dict.fromkeys(...))) and the prefix composition logic so
multiple constraint messages are combined, and ensure the function still returns
the original response_text unchanged when no critical constraints apply or when
the response already mentions the constraint (reuse _response_mentions_allergy
pattern generalized as needed).
ui/app.py (3)

126-134: Commented-out auto-reset code may confuse maintainers.

The commented block suggests first-turn auto-reset was considered but disabled. Either remove it or add a comment explaining why it's disabled.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/app.py` around lines 126 - 134, Remove or clarify the commented-out
first-turn auto-reset block: either delete the dead code lines referencing
session_active, reset_all_storage(), baseline_agent.reset(), and
ccm_agent.reset(), or replace the commented block with a short explanatory
comment stating why automatic reset on first turn was disabled (e.g., causes
state loss, moved to explicit user action, or handled elsewhere) and where the
reset now occurs; keep the codebase tidy by ensuring there are no lingering
commented-out control flows for reset behavior.

33-34: CHROMA_PATH uses absolute path; MEMORY_PATH remains relative.

CHROMA_PATH uses file-relative absolute path resolution, but MEMORY_PATH is still "data/working_memory.json" (relative to CWD). For consistency, consider making MEMORY_PATH absolute too.

♻️ Suggested fix
 CHROMA_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "chroma_db")
-MEMORY_PATH = "data/working_memory.json"
+MEMORY_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "data", "working_memory.json")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/app.py` around lines 33 - 34, CHROMA_PATH is built as an absolute,
file-relative path but MEMORY_PATH is still a CWD-relative string; change
MEMORY_PATH to construct an absolute path the same way as CHROMA_PATH by joining
the module's directory (from os.path.dirname(os.path.abspath(__file__))) with
"data" and "working_memory.json" so both are file-relative absolute paths
(update the MEMORY_PATH symbol accordingly).

523-526: Binding to 0.0.0.0 exposes server on all interfaces.

While acceptable for local development, this could expose the server on a network. Consider using 127.0.0.1 for localhost-only binding, or document the security implications.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/app.py` around lines 523 - 526, The code binds the Gradio app to 0.0.0.0
via demo.launch(server_name="0.0.0.0", ...) which exposes the server on all
network interfaces; change the server_name to "127.0.0.1" for localhost-only
binding or make the binding configurable and add clear documentation/warning
about the security implications if you must keep 0.0.0.0—update the call site
demo.launch(...) and any related config/README accordingly.
ccm/episodic_memory.py (1)

89-90: Same residual data directory creation issue.

Similar to semantic_memory.py, line 90 creates a data directory that's no longer used by CHROMA_PATH.

♻️ Suggested fix
     def __init__(self):
         os.makedirs(CHROMA_PATH, exist_ok=True)
-        os.makedirs("data", exist_ok=True)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ccm/episodic_memory.py` around lines 89 - 90, Remove the redundant creation
of the legacy "data" directory in episodic_memory.py: delete the
os.makedirs("data", exist_ok=True) call and ensure only CHROMA_PATH is created
(os.makedirs(CHROMA_PATH, exist_ok=True)); if any later code refers to "data"
update it to use CHROMA_PATH (look for references near the top-level init where
CHROMA_PATH and os.makedirs are invoked).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ccm/episodic_memory.py`:
- Line 34: The CHROMA_PATH constant in episodic_memory.py currently builds an
absolute path using os.path.abspath(__file__) which is inconsistent with test.py
and ccm_core.py; update the CHROMA_PATH definition (the CHROMA_PATH symbol in
episodic_memory.py) to use the same path strategy as the other modules (i.e.,
the relative/working-directory based path used in test.py and ccm_core.py) so
all modules resolve the "chroma_db" location consistently across the codebase.

In `@ccm/semantic_memory.py`:
- Line 32: The CHROMA_PATH constant in ccm/semantic_memory.py currently points
to "../chroma_db" which mismatches the relative "data/chroma_db" used by
ccm/ccm_core.py and tests; update CHROMA_PATH (and the analogous constant in
ccm/episodic_memory.py) to the same path used by ccm_core/test (e.g.,
"../data/chroma_db" resolved relative to the module file) so all modules persist
to the same directory; ensure the change uses
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "data",
"chroma_db") and leave ccm/ccm_core.py behavior unchanged.

In `@travel_agent/agent.py`:
- Around line 339-340: The inline comment "CHANGE THIS TO TRUE" is confusing and
inconsistent with baseline_agent.py; remove that comment and either (A) set
kwargs["parallel_tool_calls"] to False to match baseline_agent.py, or (B) keep
it True but replace the TODO-style comment with a brief explanatory comment
explaining why parallel_tool_calls must be True in this agent (mentioning any
concurrency implications). Update the single line kwargs["parallel_tool_calls"]
= True accordingly and ensure the new comment clearly states the intent.

In `@travel_agent/baseline_agent.py`:
- Line 189: The assignment self.model = "llama-3.3-70b-versatile" in
baseline_agent.py unexpectedly upgrades from an 8B to a 70B model causing higher
latency/cost and may be out-of-date vs available Llama 4 Scout; confirm intended
model and either revert to the previous model string (e.g.,
"llama-3.1-8b-instant") or update to the current preferred model (e.g.,
"llama-4-scout" or your chosen latest model) and add a short comment above
self.model explaining the rationale (performance vs cost) so future reviewers
know why this model was selected.

In `@ui/app.py`:
- Around line 175-184: The reset_conversation function is redundantly invoking
reset_budget three times (via reset_all_storage(), baseline_agent.reset(), and
ccm_agent.reset()) and it also swallows all errors with a bare except; change it
to call reset_budget exactly once (either by removing reset_budget from
reset_all_storage or by removing the standalone reset_all_storage() call and
keeping agent resets), ensure baseline_agent.reset() and ccm_agent.reset() no
longer duplicate budget reset (or make them accept a flag to skip budget reset),
and replace the bare except with a caught Exception as e that logs the error
(e.g., using the existing app logger) or re-raises after logging so failures
aren’t silently ignored; keep the same return values at the end.

---

Nitpick comments:
In `@ccm/episodic_memory.py`:
- Around line 89-90: Remove the redundant creation of the legacy "data"
directory in episodic_memory.py: delete the os.makedirs("data", exist_ok=True)
call and ensure only CHROMA_PATH is created (os.makedirs(CHROMA_PATH,
exist_ok=True)); if any later code refers to "data" update it to use CHROMA_PATH
(look for references near the top-level init where CHROMA_PATH and os.makedirs
are invoked).

In `@ccm/semantic_memory.py`:
- Around line 60-61: The code currently calls os.makedirs("data", exist_ok=True)
even though CHROMA_PATH no longer lives under data; remove that residual
directory creation or replace it by creating the parent directory of CHROMA_PATH
instead. Locate the os.makedirs("data", exist_ok=True) call in
semantic_memory.py (near the os.makedirs(CHROMA_PATH, exist_ok=True) line) and
either delete that line or change it to create os.path.dirname(CHROMA_PATH)
(guarding for empty dirname) so only the actual parent directory of CHROMA_PATH
is ensured.

In `@travel_agent/agent.py`:
- Around line 151-154: Several single-line if statements (e.g., "if addr: line
+= f\", {addr}\"", and similar uses for price, rating, warning that append to
the local variable line) violate PEP8; replace each "if x: y" with a proper
multi-line if block so readability is improved (for example: if addr:\n    line
+= f\", {addr}\"). Apply this change to all similar occurrences that append to
line (also the other flagged instances that append or modify variables at lines
handling addr/price/rating/warning and the other noted occurrences), keeping the
same condition and mutation but using full if blocks to match surrounding
function logic.
- Around line 258-295: _enforce_critical_constraints currently only checks for
shellfish in critical_facts; extend it to iterate over each fact in
memory_state.get("working_memory_raw", {}).get("facts", {}).get("critical", [])
and switch on a fact type (e.g., fact.get("type") or infer from keys like
"value" containing currency or pace indicators) to apply handlers for other
constraint types such as budget and activity pace. For budget facts, aggregate
the user's max budget and filter/annotate places from tool_calls_this_turn (same
"places_search" raw_result parsing used for allergy) to mark or remove options
over budget and add a concise budget warning to parts; for activity-pace facts,
detect pace constraints and add guidance (e.g., "low-activity" or
"high-activity" suggestions) to parts. Reuse existing de-duplication
(list(dict.fromkeys(...))) and the prefix composition logic so multiple
constraint messages are combined, and ensure the function still returns the
original response_text unchanged when no critical constraints apply or when the
response already mentions the constraint (reuse _response_mentions_allergy
pattern generalized as needed).

In `@travel_agent/baseline_agent.py`:
- Around line 166-177: BASELINE_TOOL_INSTRUCTION duplicates rules already
defined in BASELINE_SYSTEM_PROMPT; remove the redundant lines from
BASELINE_TOOL_INSTRUCTION and consolidate the canonical rules into
BASELINE_SYSTEM_PROMPT (or have BASELINE_TOOL_INSTRUCTION reference
BASELINE_SYSTEM_PROMPT) so there’s a single source of truth; keep any
tool-specific exceptions that truly belong only to tool instructions, update
comments to point to BASELINE_SYSTEM_PROMPT, and ensure the guidance about
omitting budget_per_night unless numeric remains enforced by removing that
clause from BASELINE_TOOL_INSTRUCTION and leaving it only in
BASELINE_SYSTEM_PROMPT.

In `@ui/app.py`:
- Around line 126-134: Remove or clarify the commented-out first-turn auto-reset
block: either delete the dead code lines referencing session_active,
reset_all_storage(), baseline_agent.reset(), and ccm_agent.reset(), or replace
the commented block with a short explanatory comment stating why automatic reset
on first turn was disabled (e.g., causes state loss, moved to explicit user
action, or handled elsewhere) and where the reset now occurs; keep the codebase
tidy by ensuring there are no lingering commented-out control flows for reset
behavior.
- Around line 33-34: CHROMA_PATH is built as an absolute, file-relative path but
MEMORY_PATH is still a CWD-relative string; change MEMORY_PATH to construct an
absolute path the same way as CHROMA_PATH by joining the module's directory
(from os.path.dirname(os.path.abspath(__file__))) with "data" and
"working_memory.json" so both are file-relative absolute paths (update the
MEMORY_PATH symbol accordingly).
- Around line 523-526: The code binds the Gradio app to 0.0.0.0 via
demo.launch(server_name="0.0.0.0", ...) which exposes the server on all network
interfaces; change the server_name to "127.0.0.1" for localhost-only binding or
make the binding configurable and add clear documentation/warning about the
security implications if you must keep 0.0.0.0—update the call site
demo.launch(...) and any related config/README accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 08e6240c-78cb-4da8-a140-cb6a0427d686

📥 Commits

Reviewing files that changed from the base of the PR and between 5a75334 and a36548e.

📒 Files selected for processing (6)
  • ccm/episodic_memory.py
  • ccm/semantic_memory.py
  • travel_agent/agent.py
  • travel_agent/baseline_agent.py
  • travel_agent/prompts.py
  • ui/app.py

Comment thread ccm/episodic_memory.py
Comment thread ccm/semantic_memory.py
from ccm.episodic_memory import embed # reuse the same embedding fn

CHROMA_PATH = "./data/chroma_db"
CHROMA_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "chroma_db")

@coderabbitai coderabbitai Bot Apr 19, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check all CHROMA_PATH definitions across the codebase
echo "=== CHROMA_PATH definitions ==="
rg -n "CHROMA_PATH\s*=" --type=py

echo ""
echo "=== chroma_db path references ==="
rg -n "chroma_db" --type=py -C1

Repository: mohit-bishnoii/Context-Compression-Module

Length of output: 1774


🏁 Script executed:

# Check repository root directory structure
echo "=== Repository root structure ==="
ls -la | head -20

echo ""
echo "=== Check if data and chroma_db directories exist ==="
find . -maxdepth 2 -type d -name "data" -o -name "chroma_db" 2>/dev/null | head -20

echo ""
echo "=== Check ccm_core.py logic around directory creation ==="
sed -n '95,110p' ccm/ccm_core.py

echo ""
echo "=== Check test.py comments and setup logic ==="
sed -n '1,60p' test.py | grep -A5 -B5 "chroma_db\|CHROMA_PATH"

echo ""
echo "=== Check if there are any __init__ or setup files ==="
find . -maxdepth 3 -name "__init__.py" -o -name "setup.py" -o -name "conftest.py" 2>/dev/null

Repository: mohit-bishnoii/Context-Compression-Module

Length of output: 3021


Path mismatch between memory modules and test/initialization code.

Memory modules (ccm/semantic_memory.py:32, ccm/episodic_memory.py:34) use an absolute path resolving to <project_root>/chroma_db, but:

  • ccm/ccm_core.py:98-99 creates data/chroma_db (relative)
  • test.py:33 expects ./data/chroma_db (relative)

These reference different directories. Test resets and ccm initialization target data/chroma_db, while memory modules persist to chroma_db, causing incomplete cleanup and stale data between test runs.

Align the paths across all modules.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ccm/semantic_memory.py` at line 32, The CHROMA_PATH constant in
ccm/semantic_memory.py currently points to "../chroma_db" which mismatches the
relative "data/chroma_db" used by ccm/ccm_core.py and tests; update CHROMA_PATH
(and the analogous constant in ccm/episodic_memory.py) to the same path used by
ccm_core/test (e.g., "../data/chroma_db" resolved relative to the module file)
so all modules persist to the same directory; ensure the change uses
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "data",
"chroma_db") and leave ccm/ccm_core.py behavior unchanged.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep this "./data/chroma_db"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohit-bishnoii, understood — I'll keep CHROMA_PATH as "./data/chroma_db" across all modules. I've noted this for future reviews.


✏️ Learnings added
Learnt from: mohit-bishnoii
Repo: mohit-bishnoii/Context-Compression-Module PR: 3
File: ccm/semantic_memory.py:32-32
Timestamp: 2026-04-19T02:22:52.118Z
Learning: In the mohit-bishnoii/Context-Compression-Module repository, `CHROMA_PATH` in `ccm/semantic_memory.py` and `ccm/episodic_memory.py` should use the relative path `"./data/chroma_db"` (not an absolute path derived from `__file__`). Do not suggest changing it to an absolute path.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment thread travel_agent/agent.py
Comment thread travel_agent/baseline_agent.py
Comment thread ui/app.py
Comment on lines +175 to +184
def reset_conversation():
"""Reset both agents and all state (manual reset button)."""
try:
baseline_agent, ccm_agent = get_agents()
reset_all_storage()
baseline_agent.reset()
ccm_agent.reset()
except Exception:
pass
return [], [], [], [], False

@coderabbitai coderabbitai Bot Apr 19, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Triple redundant budget reset and silent exception swallow.

reset_conversation() calls:

  1. reset_all_storage()reset_budget() (line 48)
  2. baseline_agent.reset()reset_budget() (baseline_agent.py:198)
  3. ccm_agent.reset()reset_budget() (via ccm.reset)

Also, the bare except: pass on lines 182-183 silently swallows all errors including legitimate failures.

♻️ Suggested fix
 def reset_conversation():
     """Reset both agents and all state (manual reset button)."""
     try:
         baseline_agent, ccm_agent = get_agents()
-        reset_all_storage()
         baseline_agent.reset()
         ccm_agent.reset()
-    except Exception:
-        pass
+        reset_all_storage()  # Call after agent resets to avoid redundant budget resets
+    except Exception as e:
+        print(f"[Reset] Warning: {e}")
     return [], [], [], [], False
🧰 Tools
🪛 Ruff (0.15.10)

[error] 182-183: try-except-pass detected, consider logging the exception

(S110)


[warning] 182-182: Do not catch blind exception: Exception

(BLE001)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/app.py` around lines 175 - 184, The reset_conversation function is
redundantly invoking reset_budget three times (via reset_all_storage(),
baseline_agent.reset(), and ccm_agent.reset()) and it also swallows all errors
with a bare except; change it to call reset_budget exactly once (either by
removing reset_budget from reset_all_storage or by removing the standalone
reset_all_storage() call and keeping agent resets), ensure
baseline_agent.reset() and ccm_agent.reset() no longer duplicate budget reset
(or make them accept a flag to skip budget reset), and replace the bare except
with a caught Exception as e that logs the error (e.g., using the existing app
logger) or re-raises after logging so failures aren’t silently ignored; keep the
same return values at the end.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep all

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohit-bishnoii, understood — the current behavior in reset_conversation() will be kept as-is. Just noting for future reference:

  • The triple reset_budget() calls are harmless in practice (idempotent), though slightly redundant.
  • If silent failures ever become a debugging concern, adding a print(f"[Reset] Warning: {e}") to the except block would make it easier to spot issues without changing any behavior.

No further changes needed on my end. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants