Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/codex-autoreview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Codex binary fetch dependencies
run: python3 -m pip install zstandard
- name: Fetch bundled codex binary
env:
CODEX_BINARY_RELEASE_TAG: ${{ vars.CODEX_BINARY_RELEASE_TAG || 'rust-v0.122.0' }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
python3 scripts/fetch_codex_binary.py \
--release-tag "$CODEX_BINARY_RELEASE_TAG" \
--target-triple x86_64-unknown-linux-musl
test -x codex/vendor/x86_64-unknown-linux-musl/codex/codex
- name: Codex autonomous review
uses: gersmann/codex-review-action@v1
with:
Expand All @@ -44,6 +56,18 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Codex binary fetch dependencies
run: python3 -m pip install zstandard
- name: Fetch bundled codex binary
env:
CODEX_BINARY_RELEASE_TAG: ${{ vars.CODEX_BINARY_RELEASE_TAG || 'rust-v0.122.0' }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
python3 scripts/fetch_codex_binary.py \
--release-tag "$CODEX_BINARY_RELEASE_TAG" \
--target-triple x86_64-unknown-linux-musl
test -x codex/vendor/x86_64-unknown-linux-musl/codex/codex
- name: Codex autonomous edits
uses: gersmann/codex-review-action@v1
with:
Expand Down
12 changes: 9 additions & 3 deletions codex/app_server/_protocol_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from codex.protocol import types as protocol

type RequestHandler[RequestT: BaseModel] = Callable[[RequestT], object | Awaitable[object]]
Notification = BaseModel
type Notification = protocol.ServerNotificationValue | GenericNotification
type ServerRequest = protocol.ServerRequestValue | GenericServerRequest


def method_name(message: BaseModel) -> str:
Expand Down Expand Up @@ -123,7 +124,7 @@ def parse_notification(message: JsonObject, *, strict: bool) -> Notification:
raise AppServerProtocolError(_notification_error_message(message)) from exc


def parse_server_request(message: JsonObject, *, strict: bool) -> BaseModel:
def parse_server_request(message: JsonObject, *, strict: bool) -> ServerRequest:
Comment thread
gersmann marked this conversation as resolved.
method = message.get("method")
try:
return protocol.ServerRequest.model_validate(message).root
Expand Down Expand Up @@ -151,16 +152,21 @@ def _build_known_methods(*, root_model: type[BaseModel]) -> frozenset[str]:
root_field = getattr(root_model, "model_fields", {}).get("root")
if root_field is None:
return frozenset()
annotation = _unwrap_type_alias(root_field.annotation)
methods = {
method
for candidate in get_args(root_field.annotation)
for candidate in get_args(annotation)
if isinstance(candidate, type) and issubclass(candidate, BaseModel)
for method in [_candidate_method_literal(candidate)]
if method is not None
}
return frozenset(methods)


def _unwrap_type_alias(annotation: object) -> object:
return getattr(annotation, "__value__", annotation)


def _candidate_method_literal(candidate: type[BaseModel]) -> str | None:
model_fields = getattr(candidate, "model_fields", None)
if not isinstance(model_fields, dict) or "method" not in model_fields:
Expand Down
Loading
Loading