@@ -714,6 +714,53 @@ impl ProviderRunConfig {
714714 }
715715}
716716
717+ /// Re-apply runtime options that were snapshotted into a
718+ /// [`ChildAgentRunRequest`]. Child wake/resume paths may run under a different
719+ /// parent process/config than the original spawn, so these values must travel
720+ /// with the child run marker rather than relying on the current parent config.
721+ pub fn apply_child_request_runtime_config (
722+ config : & mut ProviderRunConfig ,
723+ request : & ChildAgentRunRequest ,
724+ ) -> Result < ( ) > {
725+ let overrides = & request. config_overrides ;
726+ if let Some ( value) = config_override_str ( overrides, "browser_mode" ) {
727+ config. options . browser_mode = Some ( value) ;
728+ }
729+ if let Some ( value) = config_override_str ( overrides, "base_instructions" ) {
730+ config. options . base_instructions = Some ( value) ;
731+ }
732+ if let Some ( value) = config_override_str ( overrides, "developer_instructions" ) {
733+ config. options . developer_instructions = Some ( value) ;
734+ }
735+ if let Some ( value) = config_override_str ( overrides, "compact_prompt" ) {
736+ config. options . compact_prompt = Some ( value) ;
737+ }
738+ if let Some ( value) = config_override_u64 ( overrides, "python_tool_timeout_seconds" ) {
739+ config. options . python_tool_timeout_seconds = value;
740+ }
741+ if let Some ( value) = config_override_bool ( overrides, "model_compaction_enabled" ) {
742+ config. options . model_compaction_enabled = value;
743+ }
744+ if let Some ( value) = config_override_i64 ( overrides, "model_auto_compact_token_limit" ) {
745+ config. options . model_auto_compact_token_limit = Some ( value) ;
746+ }
747+ if let Some ( value) = config_override_str ( overrides, "model_auto_compact_token_limit_scope" ) {
748+ config. options . model_auto_compact_token_limit_scope =
749+ parse_auto_compact_token_limit_scope ( & value) ?;
750+ }
751+ if let Some ( value) = config_override_str ( overrides, "approval_policy" )
752+ . or_else ( || config_override_str ( overrides, "ask_for_approval" ) )
753+ {
754+ config. options . approval_policy = parse_approval_policy ( & value) ?;
755+ }
756+ if let Some ( value) = config_override_bool ( overrides, "use_guardian" )
757+ . or_else ( || config_override_bool ( overrides, "guardian" ) )
758+ {
759+ config. options . use_guardian = value;
760+ }
761+ Ok ( ( ) )
762+ }
763+
717764/// Parse raw `key=value` override strings into an ordered [`ConfigOverrides`].
718765///
719766/// Behavior is byte-identical to `browser-use-core::parse_config_overrides`
@@ -1484,6 +1531,28 @@ fn config_override_bool(overrides: &ConfigOverrides, key: &str) -> Option<bool>
14841531 . and_then ( |( _, value) | value. as_bool ( ) )
14851532}
14861533
1534+ fn config_override_i64 ( overrides : & ConfigOverrides , key : & str ) -> Option < i64 > {
1535+ overrides
1536+ . iter ( )
1537+ . rev ( )
1538+ . find ( |( candidate, _) | candidate == key)
1539+ . and_then ( |( _, value) | value. as_integer ( ) )
1540+ }
1541+
1542+ fn config_override_u64 ( overrides : & ConfigOverrides , key : & str ) -> Option < u64 > {
1543+ config_override_i64 ( overrides, key) . and_then ( |value| u64:: try_from ( value) . ok ( ) )
1544+ }
1545+
1546+ fn parse_auto_compact_token_limit_scope ( raw : & str ) -> Result < AutoCompactTokenLimitScope > {
1547+ match raw. trim ( ) . to_ascii_lowercase ( ) . replace ( '-' , "_" ) . as_str ( ) {
1548+ "total" => Ok ( AutoCompactTokenLimitScope :: Total ) ,
1549+ "body_after_prefix" | "bodyafterprefix" => Ok ( AutoCompactTokenLimitScope :: BodyAfterPrefix ) ,
1550+ other => bail ! (
1551+ "invalid model_auto_compact_token_limit_scope {other:?}; expected total or body_after_prefix"
1552+ ) ,
1553+ }
1554+ }
1555+
14871556/// Mirrors `browser-use-core::canonicalize_config_override_key`
14881557/// (`config_overrides.rs:35`).
14891558fn canonicalize_config_override_key ( key : & str ) -> String {
0 commit comments