Decide what happens when the page changes record
By the end of this lesson, you choose what happens when the engineer moves to another contract mid-conversation.
Handle navigation to another contract
Section titled “Handle navigation to another contract”Lesson 2 bound the conversation to &P10_CONTRACT_ID.. Lesson 2 also added a
session item, so the conversation survives a page load.
Put those together. The engineer is on contract 88, asks two questions, then navigates to contract 99. Same page, same conversation, different record.
The region has to decide what to do.
UC AI refuses to re-bind a conversation
Section titled “UC AI refuses to re-bind a conversation”UC AI binds the run context to the conversation on the first turn. A later turn can add a new key. It cannot change one that is already set.
Try it, and read the error:
declare l_sess varchar2(255 char) := 'DRIFT_DEMO'; l_r json_object_t;begin l_r := uc_ai_agents_api.execute_agent( p_agent_code => 'SC_DESK' , p_input_parameters => json_object_t('{"engineer_name":"ADMIN","today":"2026-08-25","question":"How many invoices are on this contract?"}') , p_session_id => l_sess , p_run_context => json_object_t('{"contract_id":"88"}')); sys.dbms_output.put_line('turn 1 (contract 88): ok');
l_r := uc_ai_agents_api.execute_agent( p_agent_code => 'SC_DESK' , p_follow_up_message => 'And now for the other contract?' , p_session_id => l_sess , p_run_context => json_object_t('{"contract_id":"99"}')); sys.dbms_output.put_line('turn 2 (contract 99): ok');exception when others then sys.dbms_output.put_line('turn 2 (contract 99): ' || sqlerrm);end;/turn 1 (contract 88): okturn 2 (contract 99): ORA-20507: Run context key "contract_id" is already bound to "88" and cannot be changed to "99"The conversation already holds messages about contract 88, and memory files can be stored under that binding. A move to another contract would show one customer’s conversation under another customer’s record.
The three values, and when to use each
Section titled “The three values, and when to use each”The region attribute Run Context Drift, in the Run Context group, decides what the plug-in does before it sends anything:
| Value | What happens |
|---|---|
error | The turn is refused. A notice tells the user to start a new chat. Nothing is sent and no tokens are spent. |
new_session | The plug-in starts a new conversation bound to the new contract, and sends the message there. The old conversation is still in the database, but it is no longer on screen. |
ignore | The change is ignored. The conversation keeps answering about contract 88. |
Which one is right depends on your page:
- A page about one record, where the user moves between records all day, wants
new_session. Moving to contract 99 and getting a chat about 99 is what the user means. - A page where the record should not change under an open conversation wants
error, so the user is told. ignoresuits a chat that is about something else and only reads a record in passing.
Check it yourself
Section titled “Check it yourself”Set Run Context Drift to error, send a message on contract 88, then change
P10_CONTRACT_ID to 99 and send another. The second message is refused, and the
database shows why: no new user row was written at all.
select count(*) as turns from uc_ai_chat_messages where session_id = :your_session and role = 'user';The count does not go up. The plug-in checks before it writes, so a refused turn costs nothing.
Key takeaways
Section titled “Key takeaways”- UC AI binds the run context on the first turn. A later turn can add a key, and
never change one:
ORA-20507. - Run Context Drift decides what the region does about it:
error,new_session, orignore. - Set it explicitly. An empty box does not mean the same thing in every region.
Full reference: Run context in the plug-in guide.