Skip to content

feat(evaluation): Improve iteration loop efficiency - #1101

Open
AkhileshNegi wants to merge 4 commits into
mainfrom
feature/evaluation-iteration-loop
Open

feat(evaluation): Improve iteration loop efficiency#1101
AkhileshNegi wants to merge 4 commits into
mainfrom
feature/evaluation-iteration-loop

Conversation

@AkhileshNegi

@AkhileshNegi AkhileshNegi commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Issue

Closes #PLEASE_TYPE_ISSUE_NUMBER

Summary

  • Before: The existing iteration loop had limitations that affected performance.
  • Now: The new iteration loop improves efficiency and functionality.
  • Refactoring of the loop structure was required.
  • Enhancements to the performance metrics were also implemented.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

Please add here if any other information is required for the reviewer.

Original PR description

Issue

Closes #PLEASE_TYPE_ISSUE_NUMBER

Summary

Explain the motivation for making this change. What existing problem does the pull request solve?

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

Please add here if any other information is required for the reviewer.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ready-for-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c61cf778-880d-499d-89ee-3e34a38b7e69

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions github-actions Bot changed the title Evaluation: Iteration loop feat(evaluation): Improve iteration loop efficiency Aug 3, 2026
@AkhileshNegi
AkhileshNegi marked this pull request as ready for review August 19, 2026 10:38
…eration-loop

# Conflicts:
#	backend/app/services/evaluations/fast.py
#	docs/wiki/modules/evaluations.md
@AkhileshNegi
AkhileshNegi requested a review from vprashrex August 20, 2026 05:28
@github-actions

Copy link
Copy Markdown

OpenAPI changes   🟢 1 non-breaking change

Tip

Safe to merge from an API-contract perspective.

Full changelog  ·  1
Method Path Change
🟢 POST /api/v2/evaluations/iterations endpoint added

main3bce6f80 · generated by oasdiff

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

{"finalize_node": "finalize_node", "start_improve_node": "start_improve_node"},
)
graph.add_edge("start_improve_node", "wait_improve_node")
graph.add_edge("wait_improve_node", "start_eval_node")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

wait_improve_node currently has an unconditional edge, so round_failed never reaches finalize_node and the webhook doesn't fire. Reuse route_after_eval here, mapping the continue branch to start_eval_node, so failures finalize correctly and both wait nodes follow the same pattern.

graph.add_conditional_edges(
    "wait_improve_node",
    route_after_eval,
    {"finalize_node": "finalize_node", "start_improve_node": "start_eval_node"},
)

)


def _mark_iteration_run_failed(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

here mark the row FAILED but never hit the callback_url, caller just waits forever. row already has the url, can we POST a failure report from here too?

so a caller passing an oversized value degrades to the safety cap instead of
failing outright.
"""
resolved_max_rounds = min(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Silently capping max_rounds at 25 is surprising when the caller asks for 100. Since each round costs money, we should reject invalid values instead. Add le=EVAL_ITERATION_MAX_ROUNDS_HARD_CAP to EvaluationIterationCreateRequest so FastAPI returns a 422 and the limit is reflected in OpenAPI.

just nitpick

["project_id"],
unique=False,
)

@vprashrex vprashrex Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

create index on status too, since cron is going to check status on every tick, so having index might improve the query performance.

checkpointer = get_evaluation_iteration_checkpointer()
graph = build_evaluation_iteration_graph(checkpointer)
thread_config = {"configurable": {"thread_id": str(iteration_run_id)}}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If thread_config is None, skip the eval iteration since LangGraph runs it with an empty state.

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.

2 participants