Skip to content

[Improvement] Putting all the future data into one object - #35

Open
Saaketh0 wants to merge 9 commits into
mainfrom
future-fixing
Open

[Improvement] Putting all the future data into one object#35
Saaketh0 wants to merge 9 commits into
mainfrom
future-fixing

Conversation

@Saaketh0

@Saaketh0 Saaketh0 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

In the past, metrics for each future was created by both the executor and origin nodes, with disparate data being sent back and forth, but now, we just send the entire future object back and forth, leading to one source of truth.

The executor still writes the data to its own Redis cache to be picked up by the polling global controller.

Fixing Issue #29

In addition,

  • Fixed some errors in the examples folder (syntax mainly)
  • Deduplicated two error columns in the future object
  • Created a .md with the future contents to easily see what the current future contains

Summary by CodeRabbit

  • New Features

    • Portfolio examples now use AWS Bedrock directly, with model and region configured through environment settings.
    • Future records now include execution status, results, errors, and telemetry in one unified snapshot.
    • Completion callbacks provide the complete final execution record and are sent after final metrics are stored.
  • Bug Fixes

    • Improved failure propagation, error reporting, and cross-instance future resolution.
    • Successful executions now clear stale failure information.
  • Documentation

    • Added documentation for the future record schema and field behavior.

Saaketh0 and others added 9 commits August 3, 2026 15:43
…e Redis key

Fold execution metrics (cpu/gpu, timings, LLM usage, failure details) into
the future's own hash instead of a separate :metrics key, so a single
snapshot travels between origin and executor in both request and completion
callbacks. Also fixes the completion callback firing before final metrics
(finished_at/cpu_resource/gpu_resource/agent/queue_time) were written.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Resolves conflicts between the future:{future_id}/:metrics consolidation
and origin/main's changes by keeping the consolidated-key implementation
(and layering it on top of main's telemetry_logging.py/session_logging.py
renames, stub_generator.py updates, etc.).

Also finishes a merge origin/main had left broken: portfolio/agents/
intent_agent.py had unresolved <<<<<<< HEAD markers (SyntaxError),
global_controller.yaml had leftover duplicate/incomplete agent entries,
and advisor_agent.py had dead code referencing unset self.model_id/
self.region. Resolved all three in favor of the direct
ventis.llm.bedrock.call_bedrock pattern (matching vllm_agent.py), dropping
the newly-added but unwired shared LLMAgent stub and its policy/config
references so Bedrock calls keep flowing through per-future telemetry.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
slimmed down useless function

removed useless file

removed some useless comments
@Saaketh0
Saaketh0 requested a review from iidsample August 5, 2026 23:29
@Saaketh0 Saaketh0 self-assigned this Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR unifies future execution state, results, errors, and telemetry in future:<id> Redis hashes. It updates controllers, callbacks, future handling, telemetry collection, documentation, and tests. Portfolio agents now call Bedrock directly, and the obsolete LLMAgent implementation is removed.

Changes

Unified future state and execution flow

Layer / File(s) Summary
Future hash contract and submission
ventis/FUTURE_SCHEMA.md, ventis/future.py, ventis/controller/local_controller.py
Future request, failure, result, and metadata fields now use the primary future:<id> hash. The schema documents field ownership and write rules.
Execution persistence and callbacks
ventis/controller/local_controller.py, ventis/controller/local_controller_frontend.py
Local execution writes complete future records. Callbacks wait for final persistence and send the complete snapshot.
Telemetry storage and collection
ventis/controller/utils/telemetry_logging.py, ventis/llm/bedrock.py
Telemetry scans future:* hashes. Bedrock writes usage and error counters to the unified hash without marking controller failure state.
Error, metrics, and callback validation
tests/test_error_propagation.py, tests/test_future.py, tests/test_local_controller_metrics.py, tests/test_telemetry_logging.py
Tests cover unified fields, cross-instance failure merging, callback ordering, final metadata, and revised telemetry keys.
Portfolio Bedrock integration
examples/portfolio/agents/*, examples/portfolio/config/*, examples/text2sql/agents/vllm_agent.py, examples/portfolio/agents/llm_agent.py, examples/portfolio/agents/llm_agent.yaml
Portfolio agents call Bedrock directly. The obsolete LLMAgent code and configuration are deleted. Configuration and hash-format documentation are updated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: enhancement

Suggested reviewers: iidsample

Sequence Diagram(s)

sequenceDiagram
  participant Future
  participant LocalController
  participant Redis
  participant OriginController
  Future->>Redis: Store request and created_at
  Future->>LocalController: Submit execution request
  LocalController->>Redis: Store status and final metrics
  LocalController->>OriginController: Send complete future snapshot
  OriginController->>Redis: Merge callback state
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 34.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: consolidating all future-related data into one object.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch future-fixing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ventis/llm/bedrock.py (1)

41-52: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Preserve telemetry per future across multiple Bedrock calls.

error_count resets each invocation, and hset_multiple overwrites future hash fields. If one future makes more than one Bedrock call, a later response can reset errors and replace earlier token usage. Accumulate these fields atomically, or enforce and test a one-call-per-future contract.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ventis/llm/bedrock.py` around lines 41 - 52, The finally block’s future
telemetry update must preserve accumulated usage and errors across multiple
Bedrock calls instead of resetting or overwriting prior values. Update the logic
around error_count and _redis.hset_multiple to atomically increment or merge
existing future:{future_id} fields, including token counts and errors, while
retaining current behavior for single calls.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/portfolio/agents/advisor_agent.py`:
- Around line 11-12: Update summarize to extract the first Bedrock text value,
validate that it is non-empty, and return _fallback_summary when the response is
empty instead of returning it directly. Apply the same handling to both affected
return paths while preserving the existing deterministic fallback behavior.

In `@ventis/controller/local_controller.py`:
- Around line 627-639: Update the pre-execution failure handling around
`_mark_future_failed` so the `self.agent is None` and missing-method paths do
not return with `origin` callbacks immediately. Call `_mark_future_failed`
without `origin`, then route both failures through the existing finalization
callback path so all final metrics and agent data are written before the single
callback; add remote tests covering both failure cases.

---

Outside diff comments:
In `@ventis/llm/bedrock.py`:
- Around line 41-52: The finally block’s future telemetry update must preserve
accumulated usage and errors across multiple Bedrock calls instead of resetting
or overwriting prior values. Update the logic around error_count and
_redis.hset_multiple to atomically increment or merge existing
future:{future_id} fields, including token counts and errors, while retaining
current behavior for single calls.
🪄 Autofix

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 87fb73d5-2c5b-43c1-885e-65fe35de464e

📥 Commits

Reviewing files that changed from the base of the PR and between 48f7ee7 and bdade78.

📒 Files selected for processing (17)
  • examples/portfolio/agents/advisor_agent.py
  • examples/portfolio/agents/intent_agent.py
  • examples/portfolio/agents/llm_agent.py
  • examples/portfolio/agents/llm_agent.yaml
  • examples/portfolio/config/global_controller.yaml
  • examples/portfolio/config/policy.yaml
  • examples/text2sql/agents/vllm_agent.py
  • tests/test_error_propagation.py
  • tests/test_future.py
  • tests/test_local_controller_metrics.py
  • tests/test_telemetry_logging.py
  • ventis/FUTURE_SCHEMA.md
  • ventis/controller/local_controller.py
  • ventis/controller/local_controller_frontend.py
  • ventis/controller/utils/telemetry_logging.py
  • ventis/future.py
  • ventis/llm/bedrock.py
💤 Files with no reviewable changes (4)
  • examples/portfolio/agents/llm_agent.yaml
  • examples/portfolio/config/policy.yaml
  • examples/portfolio/agents/llm_agent.py
  • examples/portfolio/config/global_controller.yaml

Comment on lines 11 to 12
# If the LLM is unavailable (returns an empty string), it falls back to a
# deterministic templated summary so the pipeline still returns.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Handle empty Bedrock output before returning.

The module documentation promises a deterministic fallback when Bedrock returns an empty string. summarize returns the first text value directly, so an empty response reaches the caller instead of _fallback_summary.

Extract and validate the text before returning it.

Proposed fix
-            return response["output"]["message"]["content"][0]["text"]
+            text = response["output"]["message"]["content"][0].get("text", "").strip()
+            if not text:
+                return self._fallback_summary(metrics, risk)
+            return text

Also applies to: 42-45

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/portfolio/agents/advisor_agent.py` around lines 11 - 12, Update
summarize to extract the first Bedrock text value, validate that it is
non-empty, and return _fallback_summary when the response is empty instead of
returning it directly. Apply the same handling to both affected return paths
while preserving the existing deterministic fallback behavior.

Comment on lines +627 to +639
# Send the completion callback only now that every final metric
# has been written, so the snapshot sent to origin is complete.
if origin and origin != self._my_endpoint:
if succeeded:
self._send_result_callback(
origin, future_id, result=serialized, failed=0, error_message=""
)
else:
error_message = self.redis.hget(f"future:{future_id}", "error")
self._send_result_callback(
origin, future_id, failed=1, error_message=error_message or ""
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Defer callbacks for pre-execution failures.

When self.agent is None or the method is missing, Lines 554-565 call _mark_future_failed(..., origin) and return before this finalization path. _mark_future_failed then sends a callback without finished_at, cpu_resource, gpu_resource, or agent.

Route these failures through this finally block. Call _mark_future_failed without origin before the single deferred callback. Add remote tests for both failure paths.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ventis/controller/local_controller.py` around lines 627 - 639, Update the
pre-execution failure handling around `_mark_future_failed` so the `self.agent
is None` and missing-method paths do not return with `origin` callbacks
immediately. Call `_mark_future_failed` without `origin`, then route both
failures through the existing finalization callback path so all final metrics
and agent data are written before the single callback; add remote tests covering
both failure cases.

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.

1 participant