Skip to content

feature: Support Opencode.session.update / AsyncOpencode.session.update #48

Description

@dsillman2000

Would it be possible to make the "update session" pattern easier? This is the only way to change properties about a session after it's been created (archive, rename, or change worktree), which requires directly using the "patch" method on Opencode/AsyncOpencode, or the _patch method on the corresponding SessionResource.

from pathlib import Path

from opencode_ai import Opencode
from opencode_ai.types.session import Session

OPENCODE_EXPERIMENTS_DIR = Path(__file__).parent.parent.absolute()

if __name__ == "__main__":
    opencode = Opencode(base_url="http://localhost:9000")
    session = opencode.session.create(
        extra_query={"directory": str(OPENCODE_EXPERIMENTS_DIR)},
        extra_body={"title": "my session ID is (tmp)"},
    )
    opencode.patch(
        "/session/" + session.id,
        cast_to=Session,
        options={
            "params": {"directory": str(OPENCODE_EXPERIMENTS_DIR)},
            "extra_json": {"title": f"my session ID is {session.id}"},
        },
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions