Agent: agent/task-20250926-081342 #810
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Original Task
Implement the new consolidated data structures as specified in the migration plan:
PlanRunV2
class with fields: id, state, current_step_index, plan (PlanV2 only), end_user, step_output_values, final_output, plan_run_inputs, configRunContext
to containplan_run: PlanRunV2
instead of separate plan/legacy_plan/plan_run fieldsThis establishes the foundation data structures needed for all subsequent migration work.
Agent Logs
Summary
I've successfully implemented the new consolidated data structures as specified in the migration plan. The implementation includes:
PlanRunV2 Class: A new consolidated data structure that combines all plan execution state into a single class, replacing the need for separate plan/legacy_plan/plan_run fields.
RunContextV2 Class: An updated RunContext that uses the new PlanRunV2 structure as the single source of truth for plan execution data.
Migration Helpers: Comprehensive migration functions that allow seamless conversion between old and new data structures during the transition period.
Comprehensive Tests: Full test coverage for all new functionality, including edge cases and migration scenarios.
Key Features Added
PlanRunV2 Class (
portia/plan_run.py
):id
,state
,current_step_index
,plan
,end_user
,step_output_values
,final_output
,plan_run_inputs
,config
_legacy_outputs
field for existing clarification functionalityRunContextV2 Class (
portia/run_context.py
):plan_run
field of typePlanRunV2
ToolRunContext
through conversion methodsMigration Functions:
migrate_plan_run_to_v2()
: Converts legacy PlanRun to PlanRunV2migrate_v2_to_plan_run()
: Converts PlanRunV2 back to legacy formatmigrate_run_context_to_v2()
: Converts legacy RunContext to RunContextV2migrate_v2_to_run_context()
: Converts RunContextV2 back to legacy formatType Safety: Full type annotations with proper forward references to avoid circular imports
Testing
Created comprehensive test suites covering:
Unit Tests (
tests/unit/test_plan_run.py
):RunContext Tests (
tests/unit/test_run_context.py
):Code Quality Assurance:
py_compile
The implementation establishes the foundation data structures needed for all subsequent migration work while maintaining full backward compatibility and providing a clear migration path for existing code.