diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 6619e705bcf92f6ea8761078e80d954baba852bd..0d7b869c9bddd4be405378bf0c90392548a23409 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -829,6 +829,10 @@ enum {
 	 *  bridge terminates, this will allow the hangup in the pbx loop to be run instead.
 	 *  */
 	AST_FLAG_BRIDGE_HANGUP_DONT = (1 << 18),
+	/*! Disable certain workarounds.  This reintroduces certain bugs, but allows
+	 *  some non-traditional dialplans (like AGI) to continue to function.
+	 */
+	AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20),
 };
 
 /*! \brief ast_bridge_config flags */
diff --git a/main/pbx.c b/main/pbx.c
index 019f2b9f681b5b21ff95b9b0341f8806f4e7cb84..2acacd23033dc9683dbbd53e98c3c890b027540d 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -9192,8 +9192,13 @@ static int pbx_builtin_background(struct ast_channel *chan, const char *data)
 	 * (but a longer extension COULD have matched), it would have previously
 	 * gone immediately to the "i" extension, but will now need to wait for a
 	 * timeout.
+	 *
+	 * Later, we had to add a flag to disable this workaround, because AGI
+	 * users can EXEC Background and reasonably expect that the DTMF code will
+	 * be returned (see #16434).
 	 */
-	if ((exten[0] = res) &&
+	if (!ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS) &&
+			(exten[0] = res) &&
 			ast_canmatch_extension(chan, args.context, exten, 1, chan->cid.cid_num) &&
 			!ast_matchmore_extension(chan, args.context, exten, 1, chan->cid.cid_num)) {
 		snprintf(chan->exten, sizeof(chan->exten), "%c", res);
diff --git a/res/res_agi.c b/res/res_agi.c
index b4396acb28688ef6ac247fed63cc00822294e59f..154ac478941fe223c53c698930301da9381da0af 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -2280,22 +2280,25 @@ static int handle_hangup(struct ast_channel *chan, AGI *agi, int argc, const cha
 
 static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
 {
-	int res;
+	int res, workaround;
 	struct ast_app *app_to_exec;
 
 	if (argc < 2)
 		return RESULT_SHOWUSAGE;
 
-	ast_verb(3, "AGI Script Executing Application: (%s) Options: (%s)\n", argv[1], argv[2]);
+	ast_verb(3, "AGI Script Executing Application: (%s) Options: (%s)\n", argv[1], argc >= 3 ? argv[2] : "");
 
 	if ((app_to_exec = pbx_findapp(argv[1]))) {
 		if(!strcasecmp(argv[1], PARK_APP_NAME)) {
 			ast_masq_park_call(chan, NULL, 0, NULL);
 		}
-		if (ast_compat_res_agi && !ast_strlen_zero(argv[2])) {
+		if (!(workaround = ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS))) {
+			ast_set_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS);
+		}
+		if (ast_compat_res_agi && argc >= 3 && !ast_strlen_zero(argv[2])) {
 			char *compat = alloca(strlen(argv[2]) * 2 + 1), *cptr;
 			const char *vptr;
-			for (cptr = compat, vptr = (argc == 2) ? "" : argv[2]; *vptr; vptr++) {
+			for (cptr = compat, vptr = argv[2]; *vptr; vptr++) {
 				if (*vptr == ',') {
 					*cptr++ = '\\';
 					*cptr++ = ',';
@@ -2310,6 +2313,9 @@ static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, const char
 		} else {
 			res = pbx_exec(chan, app_to_exec, argc == 2 ? "" : argv[2]);
 		}
+		if (!workaround) {
+			ast_clear_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS);
+		}
 	} else {
 		ast_log(LOG_WARNING, "Could not find application (%s)\n", argv[1]);
 		res = -2;