Significant-Gravitas / Significant-Gravitas/AutoGPT
Persist parent-session provenance for sub-sessions and isolate polling scope
- Dominant language
- Python
- Stars
- 187k
- Forks
- 46k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 255
Description
## Summary
Persist explicit parent-session provenance for sub-sessions created by `run_sub_session`. Use that provenance to tighten authorization in `GetSubSessionResultTool._in_caller_scope`.
## Rationale
Plain Autopilot sessions use `expert_id=None`. The current same-scope check permits `None == None` for same-user sessions because existing `run_sub_session` sub-sessions do not record their parent session. This behavior supports the existing plain Autopilot polling flow, but it does not isolate unrelated same-user plain sessions.
## Required changes
- Add a parent-session relation to sub-sessions created by `run_sub_session`.
- Persist the parent-session relation in `ChatSession` metadata or another durable session field.
- Update `GetSubSessionResultTool._in_caller_scope` to:
- allow same-expert polling only when the expert ID is non-empty and equal; or
- allow plain and cross-expert polling only when the persisted parent/delegator relation authorizes the caller.
- Preserve the current handoff ownership behavior. A session that was handed off must remain inaccessible to the source session.
- Keep the existing authenticated user ownership check.
## Affected areas
- `autogpt_platform/backend/backend/copilot/tools/run_sub_session.py`
- `autogpt_platform/backend/backend/copilot/tools/get_sub_session_result.py`
- `autogpt_platform/backend/backend/copilot/model.py`
- Related ChatSession persistence and tool tests.
## Acceptance criteria
- `run_sub_session` persists a durable parent-session relation for every created sub-session.
- An unrelated same-user plain session with `expert_id=None` cannot poll, wait on, or cancel another plain session's sub-session.
- The originating plain Autopilot session can still poll, wait on, and cancel its own sub-session.
- Cross-expert delegation remains authorized only for the recorded delegating session.
- Handoff source sessions remain unable to access handed-off sub-sessions.
- Regression tests cover the authorization cases above.
## Backlinks
- Pull request: https://github.com/Significant-Gravitas/AutoGPT/pull/14099
- Review comment: https://github.com/Significant-Gravitas/AutoGPT/pull/14099#discussion_r3832327946
- Requested by: @Abhi1992002
Contributor guide
Assessment
This issue has not been assessed yet.