Skip to content

[prompt] xml-format EnvironmentContext - #2272

Merged
dylan-hurd-oai merged 8 commits into
mainfrom
dh--ec-xml
Aug 21, 2025
Merged

dylan-hurd-oai merged 8 commits into
mainfrom
dh--ec-xml

Conversation

@dylan-hurd-oai

@dylan-hurd-oai dylan-hurd-oai commented Aug 13, 2025 •

Copy link
Copy Markdown
Contributor

Summary

Before we land #2243, let's start printing environment_context in our preferred format. This struct will evolve over time with new information, xml gives us a balance of human readable without too much parsing, llm readable, and extensible.

Also moves us over to an Option-based struct, so we can easily provide diffs to the model.

Testing

  • Updated tests to reflect new format

@github-actions

Copy link
Copy Markdown
Contributor

Summary

  • Switches environment_context from ad‑hoc text to XML via quick-xml, updates prompt building and tests accordingly. Also introduces NetworkAccess, derives Display for enums, and exposes Session.sandbox_policy as pub(crate).

Notes

  • Adds quick-xml = { version = "0.38.1", features = ["serialize"] } to codex-core (alphabetized), and bumps lockfile.
  • Implements From<&Session> for EnvironmentContext to centralize context construction.

Review

  • Clear motivation in PR body; the change is cohesive and localized. Nice test updates and minimal surface area.

Suggested tweaks

  • codex-rs/core/src/client_common.rs:@@ -19,0 +23

    • Consider aliasing the proc-macro import to avoid confusion with the trait: use strum_macros::Display as DeriveDisplay; and #[derive(DeriveDisplay)].
  • codex-rs/core/src/client_common.rs:@@ -49 +58,5

    • Display prints NetworkAccess with capitalized variants; if you prefer lowercase consistency (e.g., “restricted”), add #[strum(serialize_all = "lowercase")] to NetworkAccess or format explicitly.
  • codex-rs/core/src/client_common.rs:@@ -110,3 +132,6

    • ec.serialize(ser).ok()?; silently drops serialization errors. Consider bubbling a Result or at least logging to aid debugging.
  • codex-rs/core/src/codex.rs:@@ -222 +221

    • Instead of making sandbox_policy pub(crate), a small accessor (e.g., getters for mode/network) would keep Session encapsulation tighter.
  • codex-rs/core/tests/client.rs:@@ -394 +394 and @@ -397 +397

    • Since the format is now well-defined XML, you could assert the full message (or parse and compare) rather than prefix checks for stronger executable documentation.

View workflow run

Comment thread codex-rs/core/src/client_common.rs Outdated
self.environment_context
.as_ref()
.map(|ec| format!("{ENVIRONMENT_CONTEXT_START}{ec}{ENVIRONMENT_CONTEXT_END}"))
let ec = self.environment_context.as_ref()?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we need full on xml for this?
or can
<environment_context>
Network access: ....

</environment_context>

work? In other words, does the model care about everything being xml?

@dylan-hurd-oai
dylan-hurd-oai merged commit d2b2a6d into main Aug 21, 2025
@dylan-hurd-oai
dylan-hurd-oai deleted the dh--ec-xml branch August 21, 2025 06:45
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants