Skip to content

feat(memory): add conversation memory header contract no-op hook - #1134

Merged
slin1237 merged 5 commits into
smg-project:mainfrom
spalimpaaces-star:feat/conversation-memory-header-contract-upstream
Apr 21, 2026
Merged

slin1237 merged 5 commits into
smg-project:mainfrom
spalimpaaces-star:feat/conversation-memory-header-contract-upstream

Conversation

@spalimpaaces-star

@spalimpaaces-star spalimpaaces-star commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Problem

We need a clear request contract in SMG for conversation memory settings, including both long-term memory and short-term memory.

Solution

Add a thin contract layer in the responses flow:

  • Parse x-conversation-memory-config into a normalized internal config.
  • x-conversation-memory-config carries both:
    • long_term_memory (enabled, subject_id, embedding_model_id, extraction_model_id)
    • short_term_memory (enabled, condenser_model_id)
  • Call inject_memory_context(...) in responses routing before upstream dispatch.
  • Keep inject_memory_context(...) as a no-op stub (debug logging only) in this PR, so behavior is unchanged while establishing the contract seam.

Changes

Changes needed:

  1. Read request headers in responses route.
  2. Parse x-conversation-memory-config into ConversationMemoryConfig.
  3. Pass config to inject_memory_context(...).
  4. inject_memory_context(...) is no-op for now (logs only), so request body stays unchanged.

Implementation:

  • model_gateway/src/routers/openai/responses/header_utils.rs (new file)
    ** Added ConversationMemoryConfig, LongTermMemoryConfig, ShortTermMemoryConfig — nested structs that directly deserialize the x-conversation-memory-config JSON wire format
    ** Added extract_conversation_memory_config(headers) — returns defaults when header is absent or unparseable; normalizes blank/whitespace string fields to None; emits debug! log on parse failure
    ** Unit tests: valid JSON → all fields populated, invalid JSON → safe defaults

  • model_gateway/src/routers/openai/responses/route.rs
    ** Calls extract_conversation_memory_config in the responses request path after history loading
    ** Emits a debug! log with presence flags (not raw values) when memory is requested; actual memory injection is deferred to a follow-up PR

  • model_gateway/src/routers/openai/responses/mod.rs
    ** Exposes the new header_utils module

Test Plan

Unit tests only as this was just a no op change

Checklist
  • cargo +nightly fmt passes
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • (Optional) Documentation updated
  • (Optional) Please join us on Slack #sig-smg to discuss, review, and merge PRs

Summary by CodeRabbit

Release Notes

  • New Features
    • Added support for reading conversation memory configuration from request headers, enabling both long-term and short-term memory options
    • Implemented automatic memory context injection during request processing with configurable settings for models and identifiers
    • Enhanced logging to monitor memory configuration status and feature availability during request handling

@github-actions github-actions Bot added model-gateway Model gateway crate changes openai OpenAI router changes labels Apr 14, 2026
@coderabbitai

coderabbitai Bot commented Apr 14, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@spalimpaaces-star has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 46 minutes and 0 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 46 minutes and 0 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 04ff5078-4089-4285-810c-393dd12244e3

📥 Commits

Reviewing files that changed from the base of the PR and between 3de64bf and 44f6ae2.

📒 Files selected for processing (3)
  • model_gateway/src/routers/common/header_utils.rs
  • model_gateway/src/routers/openai/responses/history.rs
  • model_gateway/src/routers/openai/responses/route.rs
📝 Walkthrough

Walkthrough

The pull request introduces conversation memory configuration support by adding header extraction infrastructure, configuration data structures, and integration into the response routing pipeline. A new x-conversation-memory-config header is parsed to enable long-term and short-term conversation memory features with associated model identifiers.

Changes

Cohort / File(s) Summary
Header Extraction Infrastructure
model_gateway/src/routers/common/header_utils.rs
Added ConversationMemoryConfig, LongTermMemoryConfig, and ShortTermMemoryConfig structs with JSON deserialization. Implemented extract_conversation_memory_config() to parse the x-conversation-memory-config header with graceful fallback to defaults; normalizes optional string fields by trimming and converting empty strings to None. Includes unit tests for valid and invalid JSON scenarios.
Memory Context Injection
model_gateway/src/routers/openai/responses/history.rs
Added inject_memory_context() function that conditionally emits debug logs when long-term or short-term conversation memory is enabled, capturing presence of configuration fields. Currently performs logging only without modifying request data. Includes unit test verifying request body remains unchanged after function call.
Route Integration
model_gateway/src/routers/openai/responses/route.rs
Integrated memory config extraction into route_responses by importing and calling extract_conversation_memory_config() from headers. Emits debug logging when memory features are enabled, then invokes inject_memory_context() to process the prepared request body before further mutations.

Sequence Diagram

sequenceDiagram
    participant Client
    participant route_responses
    participant header_utils
    participant inject_memory
    participant request_body

    Client->>route_responses: HTTP Request + x-conversation-memory-config Header
    route_responses->>header_utils: extract_conversation_memory_config(headers)
    header_utils->>header_utils: Parse JSON, Normalize Fields
    header_utils-->>route_responses: ConversationMemoryConfig
    route_responses->>route_responses: Emit Debug Log (if memory enabled)
    route_responses->>inject_memory: inject_memory_context(config, request_body)
    inject_memory->>inject_memory: Emit Debug Log (if memory enabled)
    inject_memory-->>route_responses: (no mutations)
    route_responses->>request_body: Continue Processing
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

tests

Suggested reviewers

  • key4ng
  • CatherineSue
  • slin1237

Poem

🐰 A memory keeper hops about,
Headers parsed without a doubt,
Config structs dance in debug light,
Long and short-term, holding tight,
Tests ensure the path is right! 🧠✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: introducing a conversation memory header contract with a no-op hook in the responses flow.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mergify

mergify Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Hi @spalimpaaces-star, the DCO sign-off check has failed. All commits must include a Signed-off-by line.

To fix existing commits:

# Sign off the last N commits (replace N with the number of unsigned commits)
git rebase HEAD~N --signoff
git push --force-with-lease

To sign off future commits automatically:

  • Use git commit -s every time, or
  • VSCode: enable Git: Always Sign Off in Settings
  • PyCharm: enable Sign-off commit in the Commit tool window

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces the infrastructure for conversation memory configuration by adding a new ConversationMemoryConfig struct and a utility to extract this configuration from the x-conversation-memory-config JSON header. It also includes a stub for injecting memory context into OpenAI response requests and provides comprehensive unit tests for the new functionality. Feedback was provided regarding a discrepancy in the documentation for ConversationMemoryConfig, which incorrectly mentions support for legacy headers that are not currently handled by the extraction logic.

Comment thread model_gateway/src/routers/common/header_utils.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@model_gateway/src/routers/common/header_utils.rs`:
- Around line 20-21: The comment claims population from legacy x-smg-memory-*
headers but the implementation only reads x-conversation-memory-config JSON;
either implement legacy header mapping or tighten the doc: if you implement
mapping, update the header parsing logic that currently reads the
`x-conversation-memory-config` JSON to also look for `x-smg-memory-*` flat
headers (e.g., `x-smg-memory-type`, `x-smg-memory-enabled`, etc.),
convert/normalize those values into the same MemoryConfig struct fields, merge
them with the JSON payload with JSON taking precedence, and add unit tests
exercising both JSON-only, legacy-only and mixed inputs; otherwise simply change
the comment above the population function to state that only
`x-conversation-memory-config` JSON is supported and remove the legacy header
claim.

In `@model_gateway/src/routers/openai/responses/history.rs`:
- Line 320: The test currently only verifies the enum variant with
assert!(matches!(request.input, ResponseInput::Text(_))) but doesn't ensure the
inner string wasn't mutated; update the assertion to extract the inner text and
compare it to the original expected value. For example, pattern-match or use if
let / match on request.input (ResponseInput::Text(inner)) and assert_eq!(inner,
expected_text) (referencing request.input and the ResponseInput::Text variant
and the expected_text/original_input variable) to guarantee the payload is
unchanged.
- Around line 276-283: The debug log in history.rs currently logs the raw
subject_id (in the debug! call), which risks identifier leakage; change the
debug! invocation to avoid printing the raw value by logging presence/state
instead (e.g., use config.ltm_subject_id.is_some() or map to a constant like
"<redacted>" or "<none>" via as_deref().map(|_| "<redacted>") ), leaving the
other fields (ltm_embedding_model_id, ltm_extraction_model_id) unchanged and
keep the same message "LTM recall requested — retrieval not yet implemented".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c6697e8d-e0a6-4f10-963b-a5a45f74b169

📥 Commits

Reviewing files that changed from the base of the PR and between 50cbf82 and 2ca2689.

📒 Files selected for processing (3)
  • model_gateway/src/routers/common/header_utils.rs
  • model_gateway/src/routers/openai/responses/history.rs
  • model_gateway/src/routers/openai/responses/route.rs

Comment thread model_gateway/src/routers/common/header_utils.rs Outdated
Comment thread model_gateway/src/routers/openai/responses/history.rs Outdated
Comment thread model_gateway/src/routers/openai/responses/history.rs Outdated
@spalimpaaces-star
spalimpaaces-star force-pushed the feat/conversation-memory-header-contract-upstream branch 2 times, most recently from 936ad3d to fe1425d Compare April 14, 2026 19:15
@spalimpaaces-star
spalimpaaces-star force-pushed the feat/conversation-memory-header-contract-upstream branch from fe1425d to 18dce25 Compare April 14, 2026 19:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@model_gateway/src/routers/common/header_utils.rs`:
- Around line 61-75: The extract_conversation_memory_config function currently
maps JSON fields straight into ConversationMemoryConfig, preserving empty
strings; update the mapping in extract_conversation_memory_config to trim and
convert any "" or whitespace-only values from MemoryConfigJson (e.g.,
long_term_memory.subject_id, embedding_model_id, extraction_model_id, and
short_term_memory.condenser_model_id) into None/empty by using a helper
normalizer (or inline trim check) before assigning to ConversationMemoryConfig
so blank values aren’t treated as set by inject_memory_context; add a regression
test that parses header JSON with "" and whitespace-only values to assert they
result in the default/None-equivalent fields in ConversationMemoryConfig.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: aec9ea51-1253-4979-b38d-8d6a0e5289b5

📥 Commits

Reviewing files that changed from the base of the PR and between 2ca2689 and 18dce25.

📒 Files selected for processing (3)
  • model_gateway/src/routers/common/header_utils.rs
  • model_gateway/src/routers/openai/responses/history.rs
  • model_gateway/src/routers/openai/responses/route.rs

Comment thread model_gateway/src/routers/common/header_utils.rs Outdated
@spalimpaaces-star
spalimpaaces-star force-pushed the feat/conversation-memory-header-contract-upstream branch from 18dce25 to d028dfb Compare April 14, 2026 20:02
@spalimpaaces-star
spalimpaaces-star force-pushed the feat/conversation-memory-header-contract-upstream branch from d028dfb to 9761c77 Compare April 14, 2026 21:01
Comment thread model_gateway/src/routers/openai/responses/history.rs Outdated
Comment thread model_gateway/src/routers/common/header_utils.rs Outdated
Comment thread model_gateway/src/routers/common/header_utils.rs
Comment thread model_gateway/src/routers/common/header_utils.rs Outdated
Comment thread model_gateway/src/routers/common/header_utils.rs Outdated
@mergify

mergify Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Hi @spalimpaaces-star, the DCO sign-off check has failed. All commits must include a Signed-off-by line.

To fix existing commits:

# Sign off the last N commits (replace N with the number of unsigned commits)
git rebase HEAD~N --signoff
git push --force-with-lease

To sign off future commits automatically:

  • Use git commit -s every time, or
  • VSCode: enable Git: Always Sign Off in Settings
  • PyCharm: enable Sign-off commit in the Commit tool window

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@model_gateway/src/routers/common/header_utils.rs`:
- Around line 61-79: In extract_conversation_memory_config, when
serde_json::from_str::<MemoryConfig>(raw) fails, add a debug/warn log that
includes the HEADER_CONVERSATION_MEMORY_CONFIG name, the raw header value and
the parsing error (e.g., via log::warn! or tracing::debug!/warn!), then continue
returning the existing default ConversationMemoryConfig; this uses the existing
symbols extract_conversation_memory_config, extract_header_value,
HEADER_CONVERSATION_MEMORY_CONFIG, MemoryConfig and ConversationMemoryConfig to
locate where to insert the logging.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8e8578c8-e426-4fdc-9c0b-eeebffa38a31

📥 Commits

Reviewing files that changed from the base of the PR and between 9761c77 and cc2860a.

📒 Files selected for processing (1)
  • model_gateway/src/routers/common/header_utils.rs

Comment thread model_gateway/src/routers/common/header_utils.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f6fbdad06

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread model_gateway/src/routers/openai/responses/mod.rs Outdated
@spalimpaaces-star
spalimpaaces-star force-pushed the feat/conversation-memory-header-contract-upstream branch 2 times, most recently from 59590c1 to b85711c Compare April 15, 2026 04:23
@CatherineSue

Copy link
Copy Markdown
Member

DCO, unit test, and pre-commit all failed.

@spalimpaaces-star
spalimpaaces-star force-pushed the feat/conversation-memory-header-contract-upstream branch 2 times, most recently from 05aa31c to 75a292c Compare April 15, 2026 05:02
@spalimpaaces-star
spalimpaaces-star force-pushed the feat/conversation-memory-header-contract-upstream branch 2 times, most recently from 85ec39d to 9f546af Compare April 15, 2026 14:51

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@model_gateway/src/routers/openai/responses/header_utils.rs`:
- Around line 83-121: Add two tests covering absent header and whitespace
normalization: 1) create a test named like
extract_conversation_memory_config_with_no_header_returns_defaults that calls
extract_conversation_memory_config(None) and asserts
cfg.long_term_memory.enabled and cfg.short_term_memory.enabled are false
(defaults) and all optional IDs are None; 2) create a test named like
extract_conversation_memory_config_with_blank_values_normalizes_to_none that
inserts "x-conversation-memory-config" with either a blank string value ("   ")
and/or JSON where fields are whitespace-only (e.g.,
{"long_term_memory":{"enabled":true,"subject_id":"   ","embedding_model_id":" 
","extraction_model_id":"  
"},"short_term_memory":{"enabled":true,"condenser_model_id":"   "}}), call
extract_conversation_memory_config(Some(&headers)), assert boolean flags reflect
the enabled bits and that subject_id, embedding_model_id, extraction_model_id,
and condenser_model_id are normalized to None (use as_deref() comparisons as in
existing tests).
- Around line 43-46: The code currently drops invalid UTF-8 header values when
calling to_str().ok() on HEADER_CONVERSATION_MEMORY_CONFIG, creating a blind
spot; update the raw extraction to detect to_str() errors, log a diagnostic
(including the header name HEADER_CONVERSATION_MEMORY_CONFIG and the to_str()
error) via the existing logger (e.g., tracing::warn/error) before continuing,
and only proceed with the valid UTF-8 string for the subsequent filter and JSON
parsing; adjust the expression using a match/map_err or if let Err(...) to emit
the log and return None for malformed values so JSON parse failures remain
logged as before.

In `@model_gateway/src/routers/openai/responses/route.rs`:
- Around line 124-135: The parsed memory_config returned from
extract_conversation_memory_config is only used for debug logging and never
forwarded into the request injection path; update the routing code so the
memory_config is passed into the upstream/injection call (the same place where
hooks or request metadata are injected before dispatch) instead of being
dropped—locate extract_conversation_memory_config and the upstream
dispatch/injection function in route.rs and thread memory_config through that
call so the new no-op integration point receives it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 72acb213-8bd4-4b15-911c-c67105ae427f

📥 Commits

Reviewing files that changed from the base of the PR and between cc2860a and 9f546af.

📒 Files selected for processing (3)
  • model_gateway/src/routers/openai/responses/header_utils.rs
  • model_gateway/src/routers/openai/responses/mod.rs
  • model_gateway/src/routers/openai/responses/route.rs

Comment thread model_gateway/src/routers/openai/responses/header_utils.rs Outdated
Comment thread model_gateway/src/routers/openai/responses/header_utils.rs Outdated
Comment thread model_gateway/src/routers/openai/responses/route.rs Outdated
@spalimpaaces-star
spalimpaaces-star force-pushed the feat/conversation-memory-header-contract-upstream branch 3 times, most recently from 0380431 to 6f98aeb Compare April 15, 2026 16:03

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@model_gateway/src/routers/openai/responses/history.rs`:
- Around line 301-305: The debug log has a typo "STMO" — update the message
string in the debug! call guarded by config.short_term_memory.enabled (where it
also logs has_condenser_model =
config.short_term_memory.condenser_model_id.is_some()) to read "STM recall
requested - retrieval not yet implemented" so it matches the project's STM
terminology.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a018f034-7632-4188-8778-5e8513f5c361

📥 Commits

Reviewing files that changed from the base of the PR and between cc2860a and 6f98aeb.

📒 Files selected for processing (4)
  • model_gateway/src/routers/openai/responses/header_utils.rs
  • model_gateway/src/routers/openai/responses/history.rs
  • model_gateway/src/routers/openai/responses/mod.rs
  • model_gateway/src/routers/openai/responses/route.rs

Comment thread model_gateway/src/routers/openai/responses/history.rs
@mergify

mergify Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Hi @spalimpaaces-star, the DCO sign-off check has failed. All commits must include a Signed-off-by line.

To fix existing commits:

# Sign off the last N commits (replace N with the number of unsigned commits)
git rebase HEAD~N --signoff
git push --force-with-lease

To sign off future commits automatically:

  • Use git commit -s every time, or
  • VSCode: enable Git: Always Sign Off in Settings
  • PyCharm: enable Sign-off commit in the Commit tool window

@spalimpaaces-star
spalimpaaces-star force-pushed the feat/conversation-memory-header-contract-upstream branch from 0a22eb4 to fb2b09a Compare April 15, 2026 18:19
use serde::Deserialize;
use tracing::debug;

static HEADER_CONVERSATION_MEMORY_CONFIG: http::header::HeaderName =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

header shouldnt be part of router
we have header code in common

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.

moved it to the common module

/// Memory configuration parsed from the `x-conversation-memory-config` request header.
///
/// Returns defaults when the header is absent or unparsable.
#[derive(Debug, Clone, Default, Deserialize)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why do we have ltm memory config here?
didnt we define this elsewhere?

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.

Are you taking about the other PR? it was not merged yet. Is the concern to move these objects under some new module(memory)?

}

#[cfg(test)]
mod tests {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here
these should be moved to header

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.

Sure, moved it now.

saikiranpalimpati and others added 4 commits April 20, 2026 16:56
Signed-off-by: saikiranpalimpati <34260562+saikiranpalimpati@users.noreply.github.com>
Signed-off-by: saikiranpalimpati <34260562+saikiranpalimpati@users.noreply.github.com>
…ove inject memory,

Signed-off-by: saikiranpalimpati <34260562+saikiranpalimpati@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: saikiranpalimpati <34260562+saikiranpalimpati@users.noreply.github.com>
@spalimpaaces-star
spalimpaaces-star force-pushed the feat/conversation-memory-header-contract-upstream branch from fb2b09a to 3de64bf Compare April 21, 2026 00:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3de64bff06

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +314 to +316
use crate::routers::openai::responses::header_utils::{
ConversationMemoryConfig, LongTermMemoryConfig, ShortTermMemoryConfig,
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Fix test import to use common memory header module

The new unit test imports ConversationMemoryConfig from crate::routers::openai::responses::header_utils, but this commit defines those types in crate::routers::common::header_utils. In any cfg(test) build (e.g. cargo test -p model_gateway), this unresolved path makes the test module fail to compile, so the added coverage cannot run.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
model_gateway/src/routers/common/header_utils.rs (1)

356-426: 🛠️ Refactor suggestion | 🟠 Major

Module location appears inconsistent with the intended move.

Per a prior review thread, these memory-config types were to be moved out of routers::common into a responses-specific header module (author: "moved them to responses specific headers file"). However, ConversationMemoryConfig, its sub-structs, and extract_conversation_memory_config are still defined here in routers::common::header_utils. This also conflicts with the test in openai/responses/history.rs (see separate comment), which imports these types from crate::routers::openai::responses::header_utils.

Please either:

  1. Actually move this block to model_gateway/src/routers/openai/responses/header_utils.rs and declare it via pub mod header_utils; in responses/mod.rs, updating route.rs and history.rs imports accordingly; or
  2. Leave it in common and update the PR description, history.rs test imports, and past discussion outcome to match.

Option 1 aligns with the PR description and the Responses-specific nature of the fields.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@model_gateway/src/routers/common/header_utils.rs` around lines 356 - 426, The
memory-config types and helper (ConversationMemoryConfig, LongTermMemoryConfig,
ShortTermMemoryConfig, extract_conversation_memory_config,
normalize_optional_string) were supposed to live in the Responses-specific
header utilities but remain in routers::common::header_utils; move the entire
block to the responses header_utils module (create/modify
responses/header_utils.rs), export it via pub mod header_utils; in any files
that import these symbols (e.g., route.rs and the test in history.rs) update
imports to point to the new responses::header_utils location, run tests, and
remove the duplicate definitions from routers::common::header_utils;
alternatively if you intentionally want to keep them in common, update the PR
description and adjust the history.rs test imports to reference
routers::common::header_utils instead (but prefer moving to responses as
described).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@model_gateway/src/routers/openai/responses/history.rs`:
- Around line 309-317: The test module currently imports
ConversationMemoryConfig, LongTermMemoryConfig, and ShortTermMemoryConfig from
crate::routers::openai::responses::header_utils which doesn't exist; update the
use statement inside the tests mod (the block containing inject_memory_context
and ResponseInput/ResponsesRequest) to import these types from
crate::routers::common::header_utils instead so it matches the non-test code
import and the actual definitions.

---

Duplicate comments:
In `@model_gateway/src/routers/common/header_utils.rs`:
- Around line 356-426: The memory-config types and helper
(ConversationMemoryConfig, LongTermMemoryConfig, ShortTermMemoryConfig,
extract_conversation_memory_config, normalize_optional_string) were supposed to
live in the Responses-specific header utilities but remain in
routers::common::header_utils; move the entire block to the responses
header_utils module (create/modify responses/header_utils.rs), export it via pub
mod header_utils; in any files that import these symbols (e.g., route.rs and the
test in history.rs) update imports to point to the new responses::header_utils
location, run tests, and remove the duplicate definitions from
routers::common::header_utils; alternatively if you intentionally want to keep
them in common, update the PR description and adjust the history.rs test imports
to reference routers::common::header_utils instead (but prefer moving to
responses as described).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fd1913ba-bbd7-456f-b203-cdbc80bcb148

📥 Commits

Reviewing files that changed from the base of the PR and between 0a22eb4 and 3de64bf.

📒 Files selected for processing (3)
  • model_gateway/src/routers/common/header_utils.rs
  • model_gateway/src/routers/openai/responses/history.rs
  • model_gateway/src/routers/openai/responses/route.rs

Comment thread model_gateway/src/routers/openai/responses/history.rs
@spalimpaaces-star
spalimpaaces-star force-pushed the feat/conversation-memory-header-contract-upstream branch from 3de64bf to 8f98cc2 Compare April 21, 2026 00:35
Move ConversationMemoryConfig, LongTermMemoryConfig, ShortTermMemoryConfig,
and extract_conversation_memory_config from responses/header_utils.rs to
routers/common/header_utils.rs where shared header parsing utilities live.

Signed-off-by: saikiranpalimpati <34260562+saikiranpalimpati@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved model-gateway Model gateway crate changes openai OpenAI router changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants