Repository navigation
Show dynamic and disabled function states in the Debug tab and fix flaky agent tests - #104
Open
borisr-code-ibm wants to merge 4 commits into
Open
borisr-code-ibm wants to merge 4 commits into
borisr-code-ibm wants to merge 4 commits into
Conversation
The Debug tab read function states only when an app was selected, so a function that an app enabled or disabled at runtime, or a dynamic function that an activity registered or unregistered, kept its old state until the app was selected again. Activity-scoped (dynamic) functions looked like static ones, and their Run button always failed with FUNCTION_NOT_FOUND because the agent can't target an activity yet. - Model each function's runtime status (enabled, activity-scoped, number of registering activities) in the UI state instead of a Boolean. - Refresh the selected app's functions and statuses on every update from GetAppFunctionsUseCase, keeping inputs, expanded functions and an open result. Results of a run are applied to the latest state, so a refresh during the run isn't reverted. - Label disabled and dynamic functions with a reason, keep the header clickable so any function can be expanded or collapsed, and enable Run only for functions this screen can run. - Add unit tests for the status mapping, the live refresh and the use case's re-emission on state changes, and screenshot tests for the new rows.
- AndroidLiveAudioSessionTest: "stopAudio flushes active AudioTrack and discards queued chunks" failed in CI (2026-11-17, 2026-11-23) because it checked for the play() that follows flush() before the playback thread made it. Wait for that call. Another test in the class relied on a 30 ms sleep for a second thread to start release(); wait until that thread blocks on the state lock instead. - Instrumented tests: a shared FakeAppFunctionRule waits until the freshly installed app's functions are visible through the APIs the tests call (searchAppFunctions and getAppFunctionStates, up to 60 s, with diagnostics on timeout) instead of polling a shell command for 10 s. It also restores fakeFunction's state and drops the shell identity after each test. - New instrumented tests disable and re-enable fakeFunction at runtime and check GetAppFunctionStatesUseCase, GetAppFunctionsUseCase (isEnabled filter and re-emission) and the Debug tab's ViewModel. - CI uploads the instrumentation test results when that step fails, so the failing test is known.
A flow built on observeAppFunctions() registers its platform observer only when collected, after GetAppFunctionsUseCase has emitted its first result, so a change made right after that result could go unnoticed and time the test out. FakeAppFunctionRule.setEnabledAndAwait sets the state and, until the change shows, switches the function to the other state and back every 5 s, always ending in the requested state.
With the Disabled and Dynamic labels next to it, a medium-length name such as appendDraftMessage was shortened to "appendD…Message" on a Pixel 9. The labels now go on a line below the name. Rows of enabled global functions don't change.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I have done and why
Related to #38.
Problem
The Debug tab is where developers check their app functions, but it doesn't show how their state
changes at runtime:
enables at runtime keeps its old state until the app is selected again. The same goes for a
dynamic function that an activity registers or unregisters, and for functions added by a
reinstall.
@AppFunctionSignature(scope = AppFunctionMetadata.SCOPE_ACTIVITY), registeredwith
registerAppFunction/handleAppFunction, as discussed in Feat/dynamic function and runtime gating #94 and drafted in Feat/ChatApp-Work-Adjustments #98) look likestatic ones. Their Run button is enabled, but it always fails with
FUNCTION_NOT_FOUND: the agentdoesn't set
ExecuteAppFunctionRequest.activityId.expanded to see its parameters.
Solution
AppFunctionStatus): whether it is enabledand, for an activity-scoped function, how many activities register it right now
(
AppFunctionState.activityIds, API 37+).GetAppFunctionsUseCasealready emits again whenobserveAppFunctions()reports a metadata or state change.DebuggingViewModelnow applies eachemission to the selected app and keeps typed inputs, expanded functions and an open result.
Results of a run go to the latest state, so a refresh during the run isn't reverted.
"Disabled functions can't run."
activity that provides it". Run is disabled with "The Debug tab can't run activity-scoped
functions yet."
expanded.
strings.xml.mainRunning dynamic functions in their activity is left for #105. The Debug tab needs a way to pick one
of
activityIds, and the agent needs the foreground activity(
VoiceInteractionSession.getAppFunctionActivityId) for the overlay use case in #94.LLM payload
Unchanged. Agent Demo and Live still request
isEnabled = truetools for every turn, andGetAppFunctionsUseCaseandExecuteAppFunctionUseCasearen't changed.Flaky tests
AndroidLiveAudioSessionTest > stopAudio flushes active AudioTrack and discards queued chunksfailed in CI on 2026-11-17 (main) and 2026-11-23 (Hide specialized Gemini models in the model picker and fix the default #103) with "One matching call found, butneeds at least 2 calls".
flushActiveTrack()calls pause → flush → play on the playback thread,and the test checked for the second
play()as soon asflush()ran. With a 200 ms pause afterflush(), the old assertion fails every time. It now waits for the call(
verify(timeout = …)). Another test in the class waited 30 ms for a second thread to startrelease(); it now waits until that thread blocks on the state lock.11-24). CI doesn't keep the report, so the failing test isn't known. All three tests that run
without an API key need the freshly installed app's functions to be indexed. They waited 10 s for
a shell command and then called other APIs, never reset
fakeFunction's state, and never droppedthe shell identity. A shared
FakeAppFunctionRulenow waits up to 60 s, through the APIs the testscall, until
fakeFunctionshows insearchAppFunctionsandgetAppFunctionStates. It printsdiagnostics on timeout and restores the state and identity after each test. CI now uploads the
instrumentation results when that step fails, so a recurrence names the test. Locally (48 cores,
or pinned to 4 like a hosted runner) the step didn't fail on
mainin 16 runs, so I couldn'tconfirm the cause.
Testing
AppFunctionStatusTest(new): status mapping andcanRun.DebuggingViewModelTest: a runtime disable updates the selected app; functions added or removedat runtime show up and inputs and expanded functions are kept; an update without the app keeps
the list; a run's result isn't reverted by a refresh; dynamic functions; error paths.
GetAppFunctionsUseCaseTest: a states change event re-reads states for theisEnabledfilterin both directions; a metadata change searches again.
unregistered dynamic function; an expanded disabled function; an expanded dynamic function. The
existing references are unchanged.
pixel7Api37, the CI task):fakeFunctionis disabled and enabled atruntime and checked through
GetAppFunctionStatesUseCase,GetAppFunctionsUseCase(isEnabledfilter and a new emission after the change) and
DebuggingViewModelwith the real use cases.observeAppFunctions()registers its observer only when collected, after the use case's firstresult, so a change right after that result could be missed. The tests therefore repeat the change
every 5 s until it shows (
setEnabledAndAwait)../gradlew --continue spotlessCheck test validateScreenshotTest -PGEMINI_API_KEY=dummy_key:315/315 unit tests and 31/31 screenshot tests per flavor. The unit suites passed 5 more times in a
row.
:app:pixel7Api37StandardDebugAndroidTest, swiftshader, as in CI): 12/12 runs green on thisbranch, 8 pinned to 4 CPUs and 4 unpinned. Each run had 8 tests, and the 13 Gemini tests were
skipped because they need a key.
mainwas also green in 16/16 runs.appendDraftMessage):cmd app_function set-enabled … makeCall --state disable→ the row updates in place; the typedendpointValuestays, and Run is disabled. Back todefault→ enabled again.cmd app_function get-app-function-states. Force-stopping ChatApp while the Debug tab is onscreen → "Not registered".
Evidence
Pixel 9 emulator (API 37), with ChatApp plus a temporary activity-scoped
appendDraftMessage. Thatpatch isn't part of this PR.
mainmakeCallat runtimestill shown as enabled
updates in place, input kept
appendDraftMessagestill "Disabled"
"Registered by 2 activities"
FUNCTION_NOT_FOUNDRun disabled, with the reason
"Not registered", in place
Recording of the whole flow on this branch:
09-e2e-flow.mp4
Targets tested: agent
standarddebug (unit tests and screenshots forstandardandretail).